Your SlideShare is downloading. ×
2014
1
FOR
COMPOSER + MAGENTO
Alec Bedzir	

Head of development	

Vaimo Ukraine	

alec.bedzir@vaimo.com
Kiev, Jul 16, 2014...
HOW DO WE USUALLY START THE PROJECT
• Getting core
• Installing few already existing modules
• Developing few customizatio...
HOW DO WE MAINTAIN THE PROJECT
• Lots of useful/useless modules installed and
their list is smth difficult to get right aw...
THOUGH IN SOME TIME…
7
• It is faster and easier to implement a feature issuing
dependencies on other modules
WHY PROJECT ...
SOLUTION: LETS WATCH THE MODULES
9
CONCEPTS
• Project and modules relation should not be hardcoded
• This relation should ...
TOOLS
• Composer 

(https://getcomposer.org/)
• Magento-composer-installer

(https://github.com/magento-hackathon/magento-...
1. COMPOSER
$ mkdir bin
$ curl -s https://getcomposer.org/installer | php -- --install-dir=bin
In the project root issue:
...
2. MAGENTO-COMPOSER-INSTALLER (2)
…
"require": {
"magento/core": "1.9.0.1"
},
"repositories": [
{
"type": "composer",
"url...
4. INSTALLING MAGENTO VIA COMPOSER
$ php ./bin/composer.phar -n install
In the project root issue:
17
5. DB, USER AND PERM...
6. MAGENTO WRITABLE FOLDERS
$ chmod -R 777 ./htdocs/app/etc
$ chmod -R 777 ./htdocs/var
$ chmod -R 777 ./htdocs/media
In t...
EXPECTED RESULT . <project root>
|-- bin
| `-- composer.phar
|-- composer.json
|-- composer.lock
|-- htdocs
| |-- …
| |-- ...
SHOW TIME!
23
SPECIFICS OF VERSIONING
• Trickiest part: project has versions but modules too
• Thus, upgrade in project do...
USAGE AND BENEFITS
• Modules repos are separate and module tracking is easy
• One can’t break the module’s overall purpose...
DEVELOPING IDEA IN
• Push to module repo on BitBucket via hook informs Jenkins about new
changes
• Jenkins having successf...
29
WATCH THE MODULES!
Alec Bedzir	

Head of development	

Vaimo Ukraine	

alec.bedzir@vaimo.com
30
Upcoming SlideShare
Loading in...5
×

DevHub 3 - Composer plus Magento

382

Published on

Published in: Engineering
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
382
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
3
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "DevHub 3 - Composer plus Magento"

  1. 1. 2014 1 FOR COMPOSER + MAGENTO Alec Bedzir Head of development Vaimo Ukraine alec.bedzir@vaimo.com Kiev, Jul 16, 2014 2
  2. 2. HOW DO WE USUALLY START THE PROJECT • Getting core • Installing few already existing modules • Developing few customizations 3 4
  3. 3. HOW DO WE MAINTAIN THE PROJECT • Lots of useful/useless modules installed and their list is smth difficult to get right away • Development has introduced multiple dependencies • Development has over-customised a bunch of general purpose modules • Thanks god core is untouched 5 6
  4. 4. THOUGH IN SOME TIME… 7 • It is faster and easier to implement a feature issuing dependencies on other modules WHY PROJECT LOSE FIT • Or vice versa - some module in the project becomes kind of “customization” module storing everything • Original purpose and integrity of each separate module is not tracked by anyone • The same module in the other project is being developed in parallel instead of getting benefit from already created code 8
  5. 5. SOLUTION: LETS WATCH THE MODULES 9 CONCEPTS • Project and modules relation should not be hardcoded • This relation should be many to many and remain flexible • Module “purity” and maintenance (at least of main line) should be delegated to “module maintainer” • Module development by different teams should be done together even though being conducted in different projects • Module versions should be clear and all ready-to-use 10
  6. 6. TOOLS • Composer 
 (https://getcomposer.org/) • Magento-composer-installer
 (https://github.com/magento-hackathon/magento-composer-installer) • Whatever VCS and 11 STEPS 1) Install Composer Check the link to Github for code of all the steps (in final slides) 2) Ensure Magento-composer-installer is required 3) Create your project’s initial composer.json file 4) Install Magento files via Composer 5) Create Magento DB, user and grant permissions 6) Ensure corresponding Magento folders are writable 7) Finalise magento installation: install.php from CLI or web 12
  7. 7. 1. COMPOSER $ mkdir bin $ curl -s https://getcomposer.org/installer | php -- --install-dir=bin In the project root issue: Create empty project root folder. 13 2. MAGENTO-COMPOSER-INSTALLER … "require": { … "magento-hackathon/magento-composer-installer": "*" }, "repositories": [ { "type": "composer", "url": "http://packages.firegento.com" } ], … Add to composer.json if your project already uses composer 14
  8. 8. 2. MAGENTO-COMPOSER-INSTALLER (2) … "require": { "magento/core": "1.9.0.1" }, "repositories": [ { "type": "composer", "url": "http://packages.firegento.com" } ], … Or simply require Magento core installation in composer.json if you’re starting from scratch (Note, full version on composer.json file is shown in next step) 15 3. COMPOSER.JSON { "authors": [ { "name": "Alec Bedzir", "email": "alec.bedzir@vaimo.com" } ], "require": { "magento/core": "1.9.0.1" }, "repositories": [ { "type": "composer", "url": "http://packages.firegento.com" } ], "extra":{ "magento-root-dir": "htdocs/", "magento-deploystrategy": "copy" }, "minimum-stability": "dev" } The very basic version of the file which installs magento only with no other modules. ! File should be named composer.json and put into the root directory of the project 16
  9. 9. 4. INSTALLING MAGENTO VIA COMPOSER $ php ./bin/composer.phar -n install In the project root issue: 17 5. DB, USER AND PERMISSIONS $ mysql -u root -p -e " CREATE DATABASE magento_composer CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER magento_user@127.0.0.1 IDENTIFIED BY '123456'; GRANT ALL ON magento_composer.* TO magento_user@127.0.0.1; " Run sql for preparing Mysql infrastructure for Magento: 18
  10. 10. 6. MAGENTO WRITABLE FOLDERS $ chmod -R 777 ./htdocs/app/etc $ chmod -R 777 ./htdocs/var $ chmod -R 777 ./htdocs/media In the project root issue: 19 6. EXECUTE MAGENTO’S INSTALL.PHP $ php -f ./htdocs/install.php -- --license_agreement_accepted yes --locale en_US --timezone "America/Los_Angeles" --default_currency USD --db_host 127.0.0.1 --db_name magento_composer --db_user magento_user --db_pass 123456 --db_prefix magento_ --url "http://magento-composer.lo" --use_rewrites yes --use_secure yes --secure_base_url "http://magento-composer.lo" --use_secure_admin yes --admin_lastname Owner --admin_firstname Store --admin_email "admin@example.com" --admin_username admin --admin_password qwerty_123 --encryption_key "Encryption Key" In the project root issue: 20
  11. 11. EXPECTED RESULT . <project root> |-- bin | `-- composer.phar |-- composer.json |-- composer.lock |-- htdocs | |-- … | |-- app | |-- cron.php | |-- index.php | |-- … | `-- var `-- vendor |-- autoload.php |-- bin |-- … |-- magento `-- magento-hackathon 1) Magento was deployed to ./htdocs under the project root 2) Composer.lock file has been generated 3) Magento installation is entirely comlete 21 TROUBLESHOOTING If magento/core is not put into your htdocs directory:! ! • Check whether this is not the issue with installing outdated version: (e.g. 1.4). Be sure version is 2.0.0 and higher.
 (this can be checked in composer install operation log:
 …
 Installing dependencies (including require-dev)
 - Installing magento-hackathon/magento-composer-installer (1.4)
 …! ! • check whether you have the up-to-date version of composer! ! • check whether cache of composer is cleaned! ! • check whether you don't have any custom configuration in ~/.composer/config.json 
 (e.g. which overlaps with your per-project configuration)! ! If Magento after installation with composer throws at you
 Fatal error: Call to a member function getModelInstance() on a non-object 
 in /var/www/magento-composer/htdocs/app/Mage.php on line 463! ! • simply check the user magento files belong to and ensure app/etc/ media/ and var/ are writable. 22
  12. 12. SHOW TIME! 23 SPECIFICS OF VERSIONING • Trickiest part: project has versions but modules too • Thus, upgrade in project doesn’t mean that modules were upgraded too. Probably they were downgraded • Each project environment (dev, staging, live etc.) should be backed up by separate branch of the project repo • Forking module for customizing it to very specific needs is a good option 24
  13. 13. USAGE AND BENEFITS • Modules repos are separate and module tracking is easy • One can’t break the module’s overall purpose with his code as this will fail other projects using this module • Module get’s a “maintainer” or few of them which are responsible for main line of its development • Multiple teams working on the same module contribute to it simultaneously 25 USAGE AND BENEFITS (2) • Flexible module versions locking in the project • Modules used in the project and their versions are easy to check 26
  14. 14. DEVELOPING IDEA IN • Push to module repo on BitBucket via hook informs Jenkins about new changes • Jenkins having successfully done the build of the module (with all the checks, tests etc) updates “Vaimo packages” - our own Magento module composer repository • Composer (custom of Vaimo edition) upon next “composer update” fetches the updated packages feed and uses it for updating the project • In our internal web tool “Server portal” we track each module’s state, it’s all available versions, projects were it is installed and in which revisions 27 LINKS AND DEMO FILES Files executed during demo (for Magento entire installation and for cleanup): https://github.com/alecbedzir/composer_plus_magento_devhub_2014_Jul ! Magento-composer-installer
 https://github.com/magento-hackathon/magento-composer-installer ! Firegento - Magento Module Composer Repository http://packages.firegento.com/ ! Composer
 https://getcomposer.org/ 28
  15. 15. 29 WATCH THE MODULES! Alec Bedzir Head of development Vaimo Ukraine alec.bedzir@vaimo.com 30

×