hswner
hswner

Reputation: 592

CakePHP 3 Composer Installation Error

I am trying to create a project as shown in the official Bookmarker Tutorial using the following command:

composer create-project --prefer-dist cakephp/app bookmarker

Then I see the following errors:

[RuntimeException]
Could not load package cakephp/migrations in http://packagist.org: [UnexpectedValueException] Could not parse version constraint >=0.4.2 <1.0: Invalid version string "0.4.2 <1.0"

[UnexpectedValueException]
Could not parse version constraint >=0.4.2 <1.0: Invalid version string "0.4.2 <1.0"

Then I run bin/cake server and see the following errors:

PHP Warning: require(/Library/WebServer/Documents/bookmarker/vendor/autoload.php): failed to open stream: No such file or directory in /Library/WebServer/Documents/bookmarker/config/bootstrap.php on line 23 PHP Stack trace: PHP 1. {main}() /Library/WebServer/Documents/bookmarker/bin/cake.php:0 PHP 2. include() /Library/WebServer/Documents/bookmarker/bin/cake.php:31

Warning: require(/Library/WebServer/Documents/bookmarker/vendor/autoload.php): failed to open stream: No such file or directory in /Library/WebServer/Documents/bookmarker/config/bootstrap.php on line 23

Call Stack: 0.0010 227136 1. {main}() /Library/WebServer/Documents/bookmarker/bin/cake.php:0 0.0021 237624 2. include('/Library/WebServer/Documents/bookmarker/config/bootstrap.php') /Library/WebServer/Documents/bookmarker/bin/cake.php:31

PHP Fatal error: require(): Failed opening required '/Library/WebServer/Documents/bookmarker/vendor/autoload.php' (include_path='.:/usr/local/Cellar/php55/5.5.21/lib/php') in /Library/WebServer/Documents/bookmarker/config/bootstrap.php on line 23 PHP Stack trace: PHP 1. {main}() /Library/WebServer/Documents/bookmarker/bin/cake.php:0 PHP 2. include() /Library/WebServer/Documents/bookmarker/bin/cake.php:31

Fatal error: require(): Failed opening required '/Library/WebServer/Documents/bookmarker/vendor/autoload.php' (include_path='.:/usr/local/Cellar/php55/5.5.21/lib/php') in /Library/WebServer/Documents/bookmarker/config/bootstrap.php on line 23

Call Stack: 0.0010 227136 1. {main}() /Library/WebServer/Documents/bookmarker/bin/cake.php:0 0.0021 237624 2. include('/Library/WebServer/Documents/bookmarker/config/bootstrap.php') /Library/WebServer/Documents/bookmarker/bin/cake.php:31

My system is OS X Yosemite 10.10.2, my PHP version is 5.5.21 and intl extension is enabled.

Are there anyone who had this issue or similar? Any solutions?

Upvotes: 4

Views: 8018

Answers (3)

Ivan Vercinsky
Ivan Vercinsky

Reputation: 1

if you go into your app folder and run

composer install 

it might fix it.

If fix it for me!

Thanks

Upvotes: -2

Dooltaz
Dooltaz

Reputation: 2463

The latest way to install CakePHP 3.2 is:

curl -s https://getcomposer.org/installer | php

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

First find out which version of PHP you are using, and find out where it is located.

> php -v
PHP 5.5.34 (cli) (built: Apr 22 2016 19:16:58) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

> which php
/usr/bin/php

You need to have php version 7 as the primary one. I know of two options for you.

  1. Copy the MAMP php file over to replace your /usr/bin/php file (you may also want to back it up.

    (sudo mv /usr/bin/php /usr/bin/php5.5.34; sudo cp /Applications/MAMP/bin/php/php7.0.0/bin /usr/bin/php)

  2. Order your system $PATH variable to the MAMP path for your php7 bin directory. You can also add this line to your ~/.profile so it will load every time you start the terminal.

    export PATH="/Applications/MAMP/bin/php/php7.0.0/bin:$PATH";

Once these changes are made, you should be able to install cake without a problem, and your cake bake commands should also work.

Upvotes: 0

Konstantin
Konstantin

Reputation: 25339

Run following command first (you might need to prepend this with sudo if composer was installed globally)

composer self-update 

then again

composer create-project --prefer-dist cakephp/app bookmarker

Upvotes: 6

Related Questions