user1852196 user1852196 - 1 year ago 193
PHP Question

Creating a cakephp project using composer and setting the path

I have Composer installed globally, So I open CMD and write the following command to create a project (composer create-project --prefer-dist cakephp/app my_app_name). What this does is install the project in my user folder. I need the project to be installed in wamp/www folder. And I can't for the life of me figure out how to set the path. Should I just cut-paste the project there or will that create issues with cakephp? still new to the framework :)

Any help would be appreciated. Thanks.

Answer Source

Installing CakePHP

Before starting you should make sure that you have got an up to date PHP version:

php -v

You should at least have got installed PHP 5.5.9 (CLI) or higher. Your webserver’s PHP version must also be of 5.5.9 or higher, and should best be the same version your command line interface (CLI) PHP version is of.

Installing Composer

CakePHP uses Composer, a dependency management tool, as the officially supported method for installation.

Installing Composer on Linux and Mac OS X

Run the installer script as described in the official Composer documentation and follow the instructions to install Composer.

Execute the following command to move the composer.phar to a directory that is in your path:

mv composer.phar /usr/local/bin/composer

Installing Composer on Windows

For Windows systems, you can download Composer’s Windows installer here. Further instructions for Composer’s Windows installer can be found within the README here.

Create a CakePHP Project

Now that you’ve downloaded and installed Composer, let’s say you want to create a new CakePHP application into my_app_name folder. For this just run the following composer command:

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

Or if Composer is installed globally:

 composer self-update && composer create-project --prefer-dist cakephp/app my_app_name

Once Composer finishes downloading the application skeleton and the core CakePHP library, you should have a functioning CakePHP application installed via Composer. Be sure to keep the composer.json and composer.lock files with the rest of your source code.

First point your composer to www folder.In my case i am using Xamp so pointed my composer to htdocs

 C:\xampp\htdocs>composer create-project --prefer-dist cakephp/app my_app_name

Installing cakephp/app (3.3.2)
  - Installing cakephp/app (3.3.2)
    Downloading: 100%

Created project in my_app_name
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.


I am using windows .


C:\>cd xampp

C:\xampp>cd htdocs


Also in windows if i right click on inside htdocs any folder i have option to use composer here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download