hswner hswner - 5 months ago 96
PHP Question

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?

Answer

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