Failed to open stream

I’m just starting with CakePHP but having trouble running my first testing application.
I have creates a new PROJECT using

php composer.phar create-project --prefer-dist cakephp/app test

apparently with success, but when I enter the site, I see the following error:

**Warning** : require(/var/www/html/test/vendor/autoload.php): failed to open stream: No such file or directory in **/var/www/html/test/webroot/index.php** on line **31**

**Fatal error** : require(): Failed opening required '/var/www/html/test/vendor/autoload.php' (include_path='.:/usr/share/php') in **/var/www/html/test/webroot/index.php** on line **31**

I verified and the mentioned file:
does not exist, perhaps It should, I think.

Please, can someone tell me How can I fix it?

how did you install cake? did you used method from book?

woop sorry tried to reply too fast,
you can try
composer dumpautoload

Thanks for your reply, Graziel,
I used the mentioned method:

]php composer.phar create-project --prefer-dist cakephp/app test

as mentioned in the documentation.
I’ve forgot to execute the following (also mentioned in documentation):

]bin/cake server

That is not found, because I don’t know where was CakePHP installed.


and what about
composer dumpautoload ?

/var/www/html$ composer dumpautoload
Composer could not find a composer.json file in /var/www/html
To initialize a project, please create a composer.json file as described in the “Getting Started” section

I told installing CakePHP was an easier task.

and what about

php composer.phar dumpautoload

cake installation is strightforward but your composer is not installed globally

I executed the following, inside one of my projects, that contain a composer.json file:

composer dumpautoload

and this is the output:

Generating autoload files Class Cake\Composer\Installer\PluginInstaller is not autoloadable, can not call post-autoload-dump script

There is still something missing, I guess

try to add it manually

composer require cakephp/plugin-installer:*

If @Graziel’s suggestion doesn’t work, would you mind posting your composer.json?

I executed:

and the response:
[CODE[Using version ^1.1 for cakephp/plugin-installer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing cakephp/plugin-installer (1.1.0): Downloading (100%)         
Writing lock file
Generating autoload files


$ composer dumpautoload Generating autoload files $ bin/cake server
at last, the command indicated in the book
bash: bin/cake: No existe el archivo o el directorio
that is: file or directory does not exist

try running composer require cakephp/bake

Fine, executed command

composer require cakephp/bake

with no flaws.

I Now have generated a new project:
using command:

php composer.phar create-project --prefer-dist cakephp/app bookmarker

successfully, at least in appearance.
When I open site
I get the following response:

**Warning** : require(/var/www/html/bookmarker/vendor/autoload.php): failed to open stream: No such file or directory in **/var/www/html/bookmarker/webroot/index.php** on line **31**

**Fatal error** : require(): Failed opening required '/var/www/html/bookmarker/vendor/autoload.php' (include_path='.:/usr/share/php') in **/var/www/html/bookmarker/webroot/index.php** on line **31**

So, I suspect composer is not creating missing file
… and maybe others.

Including my composer.json file would be a good idea, how can I do that?

open it in your IDE and slap it here between three backticks.

    "name": "cakephp/app",
    "description": "CakePHP skeleton app",
    "homepage": "",
    "type": "project",
    "license": "MIT",
    "require": {
        "php": ">=5.6",
        "cakephp/cakephp": "3.6.*",
        "cakephp/migrations": "^2.0.0",
        "cakephp/plugin-installer": "^1.0",
        "josegonzalez/dotenv": "3.*",
        "mobiledetect/mobiledetectlib": "2.*"
    "require-dev": {
        "cakephp/bake": "^1.1",
        "cakephp/cakephp-codesniffer": "^3.0",
        "cakephp/debug_kit": "^3.15.0",
        "psy/psysh": "@stable"
    "suggest": {
        "markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
        "dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility.",
        "phpunit/phpunit": "Allows automated tests to be run without system-wide install."
    "autoload": {
        "psr-4": {
            "App\\": "src/"
    "autoload-dev": {
        "psr-4": {
            "App\\Test\\": "tests/",
            "Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
    "scripts": {
        "post-install-cmd": "App\\Console\\Installer::postInstall",
        "post-create-project-cmd": "App\\Console\\Installer::postInstall",
        "post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump",
        "check": [
        "cs-check": "phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
        "cs-fix": "phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
        "test": "phpunit --colors=always"
    "prefer-stable": true,
    "config": {
        "sort-packages": true

Seems like it’s pretty much the same as mine.
You could try to remove everything in the directory but the composer.json (so only leaving the composer.json) then running composer install.
It should download everything again and have you start with everything needed.

1 Like

sorry for bring this old post from last year, i did have the same issue than obsidiana, but ur recommendation worked well for me! After i did remove everything what u said, i did composer working with composer.json (worked without problems), and creating again the new cake project, moved to the same project where composer.json is. After everything, with cake server worked and running now. im glad to find that issue! Please pin this to people check this if everyone does have the same situation like me and obsidiana. Laters!

I had same problem.
The solution for me that was the next:
When I install the cake with composer, I got the error message:
phpunit/phpunit 8.5.8 requires ext-dom * -> the requested PHP extension dom is missing from your system
The installation of php-dom then remove cakephp folder and install the cakephp with composer again is solved the problem.

I have the same problem

i tried to create project ver 4.3.6 to v 4
the same error comes
i uninstalled composer and clean cache files
i tried also to download the project from github
the same
any help please