php - Slim Framework - 404 Page Not -


i came across slim framework , have been playing it. i'm running 404 issue. code below: know has url i'm not quite sure how fix problem. have define url "profiles" somewhere?

also directories this:

include

  • dbhandler.php

  • config.php

  • dbconnect.php

lib

  • slim

v1

  • .htaccess
  • index.php

problem in code: mysite.com//parentfolder/v1/profiles throws 404 error

$app->post('/profiles', 'authenticate', function() use ($app) {             // check required params             verifyrequiredparams(array('gender'));              $response = array();             $gender = $app->request->post('gender');              global $user_id;             $db = new dbhandler();              // creating new task             $profile_id = $db->createuserprofile($user_id, $gender);              if ($profile_id != null) {                 $response["error"] = false;                 $response["message"] = "profile created successfully";                 $response["profile_id"] = $profile_id;                 echorespnse(201, $response);             } else {                 $response["error"] = true;                 $response["message"] = "failed create profile. please try again";                 echorespnse(200, $response);             }             }); 

.htaccess

rewriteengine on   rewritecond %{request_filename} !-f   rewriterule ^(.*)$ %{env:base}index.php [qsa,l] 

i have function works fine.

$app->post('/register', function() use ($app) {             // check required params             verifyrequiredparams(array('name', 'email', 'password'));              $response = array();              // reading post params             $name = $app->request->post('name');             $email = $app->request->post('email');             $password = $app->request->post('password');              // validating email address             validateemail($email);              $db = new dbhandler();             $res = $db->createuser($name, $email, $password);              if ($res == user_created_successfully) {                 $response["error"] = false;                 $response["message"] = "you registered";             } else if ($res == user_create_failed) {                 $response["error"] = true;                 $response["message"] = "oops! error occurred while registereing";             } else if ($res == user_already_existed) {                 $response["error"] = true;                 $response["message"] = "sorry, email existed";             }             // echo json response             echorespnse(201, $response);         }); 

assuming /parentfolder/v1/ physical folder code lives. add following .htaccess.

rewritebase /parentfolder/v1/ 

i not sure env:base comes from. unless sure must use it, use rewrite rules instructed in slim documentation.

rewriteengine on rewritebase /parentfolder/v1/ rewritecond %{request_filename} !-f rewriterule ^ index.php [qsa,l] 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -