Upgrade to Pro — share decks privately, control downloads, hide ads and more …

London Magento Meetup - 5 March 2014

London Magento Meetup - 5 March 2014

Steve Desmet

March 05, 2014
Tweet

Other Decks in Technology

Transcript

  1. <3

  2. Why should you care? No need to add (Magento) extension

    code (connect, private, commercial) to project code (magento base dir) in VCS
  3. What's wrong with Magento Connect? • For merchants it's a

    nice feature • Extensions need to either be in tarball format or on Connect • What about private/commercial extensions?
  4. composer.json { “require”: { “magneto/debug”:”*” }, “require-dev”: { “ivanchepurnyi/ecomdev_phpunit”:”*” },

    “repositories”: [ { “type”:”composer”, “url”:”packages.firegento.com” } ], “extra”: { “magento-root-dir”:”./” } }
  5. Project start $ cd /var/www/magento $ vim composer.json $ composer

    validate $ composer install $ n98-magerun.phar dev:module:rewrite:conflicts $ echo 'vendor/' >> .gitignore $ find . -type l | cut -c 3- >> .gitignore $ git add composer.json composer.lock .gitignore $ git commit -v
  6. Versioning constraints “require”: { “vendor/package”:”VERSION CONSTRAINT” } • EXACT “1.0.0”

    “dev-master” • RANGE “>=1.0” • WILD CARD “1.0.*” (equals >=1.0, <1.1) “*” • NEXT SIGNIFICANT RELEASE ~1.7 (equals >=1.7, <2.0)
  7. Version constraints - Tags 1.1.1 – v1.1.1 1.1.1-alpha1 1.1.1-beta1 1.1.1-RC1

    1.1.1-patch1 (v)X.Y.X-[alpha|beta|RC|patch][0-9]* Tags are stable and generate dist packages
  8. Version constraints - Branches 1.0 => 1.0.x-dev master => dev-master

    Branches always have DEV stability and generate source packages VCS composer
  9. Workflow: add new dependency $ cd /var/www/magento $ vim composer.json

    $ composer validate $ composer.phar update $ n98-magerun.phar dev:module:rewrite:conflicts $ echo 'vendor/' >> .gitignore $ find . -type l | cut -c 3- >> .gitignore $ git add composer.json composer.lock $ git commit -v
  10. Workflow: delete a dependency There is no `composer remove` command

    Remove dependency from composer.json “require” key and run `composer update` $ rm -rf `find -L . -type l`
  11. Make your Magento extension composerable! { “name”:”vendor/package”, “description”:”My awesome extension”,

    “license”:[”MIT”], “type”:”magento-module”, “require”: { “magento-hackathon/composer-installer”:”*” } } Your extension already has modman or package.xml file?
  12. Create your own and publish { “name”:”vendor/package”, “description”:”My awesome extension”,

    “license”:[”MIT”], “type”:”magento-module”, “require”: { “magento-hackathon/composer-installer”:”*” }, “extra”: { “map”: [ [“source/path”,”destination path”], [“source/path”,”destination path”] ] } } No modman, package.xml?
  13. Mappings • Create mappings based on the module configuration •

    Outputs a modman file php -f modman_files.php -- --module_name=Mage_Catalog --prefix="mycustom_dir"
  14. Updating package $ cd /tmp $ git clone <package> $

    cd package $ rm -rf * $ unzip / tar <new package> $ git add --update $ git add <any new files or folders> $ git checkout composer.json // Make sure you add mappings for any new files $ vim composer.json $ git commit -v
  15. Publish changes $ composer.phar install --prefer-source $ composer.phar status --verbose

    If “minimum-stability”:”stable”, composer download, not clone packages
  16. Deployment $ git clone [email protected]:... $ composer.phar install --prefer-dist $

    composer.phar create-project vendor/package \ --repository-url=”http://p.yourcomp.com” \ --stability=”stable” \ --prefer-dist \ --no-dev \ --no-interaction \ 1.0.0 Production $ composer.phar create-project vendor/package \ --repository-url=”http://p.yourcomp.com” \ --stability=”dev” dev-master Dev
  17. Install Magento Core as dependency { "require": { "connect20/mage_all_latest":"*" },

    "repositories": [ { "type":"composer", "url":"http://packages.firegento.com" } ], "extra": { "magento-deploystrategy":"copy", "magento-root-dir":"./", "magento-force":"1" } }
  18. Autoloader Accessing vendor folder from within Magento project https://gist.github.com/anonymous/8488849 {

    "minimum-stability":"dev", "require": { "pear-pear/Net_IPv4":"v1.3.4", "firegento/psr0autoloader":"*" }, "repositories": [ { "type": "composer", "url": "http://packages.firegento.com" }, { "type":"pear", "url":"pear.php.net" } ], “extra”: { “magento-root-dir”:”./” }
  19. Lessons learned • Allow symlinks Magento config • Adding untracked

    composer extension files to repository • Difference between composer install/update.. Do NOT run composer update on a production server • After composer update, also update .gitignore file • Make sure composer.lock is added after update • When un-installing, sometimes dangling symlinks left behind • Windows users.. symlink support (use Cygwin).. Older version use copy-deploy • Developers not familiar with command line • Updating private packages • Creating mappings for linking into base install