We have one Gruntfile.js that looks like this on my coworker's machine.
php: {
dist: {
options: {
port: 8888,
useAvailablePort: true,
keepalive: true,
router: '_router.php',
base: 'src' //dev mode
}
}
},
...and it works fine on his machine but not mine. _router.php
is at the top level directory. Running grunt dev
leads into no errors in my console during dev deploy.
PHP 5.5.27 Development Server started at Wed Sep 23 17:31:54 2015
Listening on http://127.0.0.1:8888
Document root is /Users/toszter/Engineering/moo/sources/local/web/src
Press Ctrl-C to quit.
[Wed Sep 23 17:39:33 2015] 127.0.0.1:53910 Invalid request (Unexpected EOF)
Yet, I see in my browser at localhost:8888...
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required '_router.php' (include_path='.:') in Unknown on line 0
Changing the router
property in the code above to router: 'src/_router.php'
fixes the problem on my machine, but breaks everyone else.
So it stands needing a bit of explanation: Why do I need to re-specify the base directory explicitly in my router
property and no one else on my team?
Possibly because path.resolve
isn't providing absolute paths to the php script spawned in the task by using the simple options given and options.base
to join the true path to the router.
While the task expects a full path to router
inside spawn
, it only gets the relative path from options.router
inside php.js
, which pukes rainbow unicorn sparkles everywhere.
The original issue is here. That was eventually fixed here, and yet this problem persisted, so it now appears fixed here but not yet merged with grunt-php
master.