When I start it with cd /www && php -S localhost:8000 ../kirby/router.php I get errors in Kirby/router.php (assuming because the $root var doesn’t point to the correct __DIR__). If I omit the router script the server starts up but then no media is found.
Any thoughts on this?
Also: Can the /media folder also be placed outside the webroot?
Thanks!
please read the “public folder setup” in the docs. apart from naming the public folder www i think it should solve your problem.
a note aside: using relative paths with /../ might need a wrapping realpath(). but i do not think thats the problem here. just follow the public folder setup.
you might need to change the router php but someone else needs to comment on that because i never use that one. mamp/xampp/valet/homestead are mostly free and provide a more well rounded solution especially when debugging with xdebug.
since i use the public folder myself exclusively i created a modified version of the plainkit which you can use as reference or clone. but its intended to be used with composer so i am not sure it fits your needs today.
For using PHP’s CLI router, the only workable approach I’ve found is to create a custom “router” file to replace Kirby’s default (kirby/router.php). When doing this, copy Kirby’s router.php file and change this line
$root = dirname(__DIR__);
to this
$root = __DIR__;
It’s a good idea to name the custom router file something like devRouter.php (to make it clear that it’s only for use locally, for development purposes). Place it in the root of your public/ww folder.
It’s also likely a good idea to leave a big comment in the file to explain that it’s modified from Kirby’s router.php file.