php - Slim framework - cannot interpret routes with dot -
problem statement
i'm working on internal restful api, , i'm using our main domain name environment identifier. however, noticed slim not @ route have dot in there.
sample casei have local web server running using php's built-in webserver, , invoked php -s 0.0.0.0:5000 running.
once web server up, have simple 'hello world' on index page. everything's working fine , dandy.
i set route following:
$app->get('/:domain/:id', function($domain, $id) { echo $domain . ' ' . $id; } with this, set route hopefully resolve 0.0.0.0:5000/apple.com/juicers. tried 0.0.0.0:5000/apple/juicers , page prints out apple juicers. 0.0.0.0:5000/apple.com/juicers, 404 not found error.
i looked available resources on google, , slim framework's github issues well. seems encountered similar issue: https://github.com/codeguy/slim/issues/359
the proposed solution in ticket was: url rewriting fix. tried no avail. set .htaccess @ root of project directory, , turned on allowoverride all in mac's httpd.conf file.
instead of running php -s 0.0.0.0:5000 itself, ran command on index.php. @ point, instead of throwing not found error, slim framework resolving base of operations route, set follows:
$app->get('/', function() { echo "hello world"; }); thank you i'm @ wit's end, , help highly appreciated. give thanks much reading!
root issue - php development server
after playing different slim conditions , experiments, started closer @ server level , making sure url passed correctly slim routes.
turns out issue php's development server, available through php -s command.
a quick google search revealed several others had encountered same issue, , server issue, rather bug in slim.
solutionto test out solution, ran mamp, , transferred files over. , wrote .htaccess redirect requests through index.php.
the moment of truth:
i typed in localhost:8888/campaigns/demo.com/12 , wave of joy surged through veins saw line of beautiful, gorgeous demo.com/12 written across browser! (i have echo statement particular route) week-plus of troubleshooting , tinkering around has bore fruit!
\(^o^)/ hoorah apache!
thanks help @adosaiguas!
php apache .htaccess frameworks slim
No comments:
Post a Comment