Search code examples
phpwindowsapachepearchmod

PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0


I start with PHP, wampserver and Composer on windows 10 and it will be a week that I can not fix this problem: When I type:

php -S localhost:8000 -d display_errors = 1 public/

on the browser by running: "localhost:8000/test", I have this error:

Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

Fatal error: Unknown: Failed opening required 'public/' (include_path = '.;C:\wamp64\bin\php7.1.9\pear') in Unknown on line 0

I installed the famous "pear", I modify the access mode to my project with:

chmod -R 777 or 755 myFramework

I even touched php.ini in apache folder and in php folder to add this line :

include_path
= '.;C:\wamp64\bin\php7.1.9\pear'

But nothing is working ! Can you help me ?


Solution

  • The command line is wrong.

    From man php or from the PHP CLI online Manual :

    • First

      --define foo[=bar]

      -d foo[=bar] Define INI entry foo with value bar

    (note that there is no space before and after the = sign)

    • Second

      --docroot docroot

      -t docroot Specify the document root to be used by the built-in web server

    (you need to specify the document root with the -t parameter)

    So, the final command will look like this :

    php -S localhost:8000 -d display_errors=1 -t public/
    

    And it should work as expected.