Wednesday, August 19, 2015

Re: Trying to integrate composer with an existing Cake 2.5 application

Hi, 

I am new to here. So not familiar with Cake 2.5 and how it works. These are just my thoughts. You need to experiment and see if it works for you. My hope is it will work. 

WARNING : Test before you push to production.

Writing inline.

I have an existing CakePHP 2.5 project where CakePHP has been manually installed. I want to use the features of composer to manage the project's dependencies including Cake.

Right now, the project has a folder structure such as:

project_root/
 app/
   Config/
   Controller/
   Lib/
   Model/
   Plugin/
   Vendor/ [1]
     cakephp/ [2]
   View/
   webroot/
  composer.json [3]
 lib/ [4]
   Cake/
 plugins/
 vendors/

From my understanding of how composer works, it will install its dependencies to Vendor [1], and Vendor/cakephp [2] should have the latest CakePHP source defined on composer.json [3].
However, the project has the lib/Cake folder that also contains CakePHP source.

My questions:
1. This project is managed by git. What should I commit to git that won't break anything else? The production server is running off a git branch.

You don't need to commit the vendor folder. Run composer install from server where composer.json file resides.

This will install the dependencies on the sever depending on the composer.lock you have committed.
 
2. Should I remove the lib folder? [4]

Yes, you can safely remove the lib folder.
 

In the "Installing CakePHP with Composer", it mentions "Save this JSON into composer.json in the APP directory of your project.". How can I have an app directory if I'm still installing Cake? I got confused here.

You already have an app directory . See project_root/app folder . What ever case, just add online 

require "path to where vendor/autoload.php" 

to the webroot/index.php file.

Composer will automatically load the necessary classes as it is defined https://github.com/cakephp/cakephp/blob/master/composer.json#L35 .

Hope that helps to move on.

Thank you.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: