magento 2 workflows

36
Smooth M2 Workflows

Upload: ryan-street

Post on 12-Apr-2017

1.804 views

Category:

Technology


0 download

TRANSCRIPT

Smooth M2 Workflows

• Challenges• Solutions• Helpful Tools• Recommendatio

ns• Q/A

Agenda

My Story

The Process

Challenges

• Scalable• Assumptions

of Skill• Lynchpins

• Too Complicated• Not Automated• Too Many

Assumptions• I Thought Others

Would Care

Mistakes

• KISS• Guides, Not Rules• Optimize Mercilessly• Right Process For The Right Team• Draw Your Line In The Sand

Lessons Learned

• Keep Developer Freedom?• Maintain Code Integrity?• Keep Accountability?

Developer Setup

• *nix (Unix / Linux) based OS

• All Extensions must match appropriate versions– PHP– Apache / NGinX– MySQL– Etc…

• TESTS MUST PASS!

Developer Setup

• Keep Track of Changes Effectively?• Reduce Conflicts and Reconciliation?• Code Promotion?

Code Management

• Git / Github• Git Branching

System

Code Management

• What Tools?• Scalability?• Non-versioned Assets?

Code Promotion

Code Promotion

• Deploybot• Git / Github• Composer• M2 Command

Line

Tools

• Vagrant• PHPStorm /

IDE• Composer• Git / Github

Tools

Vagrant

• Simplify Developer Setup• Easily Distributed Environment• Flexible• Expandable (Docker / AWS / etc.)

Vagrant• Used Simple Vagrantfile and Shell Script• Kept Files in Version Control• Allowed Simple Developer Setup

$ ~/ git clone [email protected]:username/repo.git$~/ vagrant up

Vagrant Performance• If it doesn’t change, don’t

mount it!• Increase CPUs and Memory for

the Box• Symlink var/ directories to

/tmp/magento/var/*• NFS mount (except var/)• Consider Vmware• Consider Docker

Consider Building Your Own Box

Vagrant

PHPStorm

• Code Completion

• Automated Code Sniffs

• Integrated Testing

• Xdebug Support• Code Templates

PHPStorm

• Complete URNs$ ~/ php bin/magento dev:urn-catalog:generate ./misc.xml

PHPStorm

PHPUnit Integration

• Mess Detector• ECG Standards• PSR Standards

Code Sniffs

Code Sniffs

WorkFlow

Git Repository Structure

{root} - Vagrantfile - ClientName/ - Module01/ - Module02/ - Module03/

Each module is packaged separately. This allows maximum flexibility.

Git Repository Structure

$ ~/ git clone [email protected]:company/clientrepo.git$ ~/ git checkout –b mybranch develop$ ~/ vagrant up

Developer WorkFlow

• Code is kept in separate repo• Maintained and deployed in branches (dev, stage, prod, etc.)• Allows faster deployments and rollbacks• Client code is kept as artifacts on the server.• Composer.json points to directory that holds all artifacts.

Deployment

$ ~/ git clone [email protected]:username/clientserverrepo.git$ ~/ git checkout -b <branchname>$ ~/ composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition ./$ ~/ git commit –m “…”$ ~/ composer require clientname/module01 clientname/module02 (etc.)$ ~/ php bin/magento deploy:mode:set <mode>$ ~/ php bin/magento module:enable Client_Module01 Client_Module02$ ~/ php bin/magento setup:upgrade$ ~/ git commit –m “…”

Server Setup

$ ~/ git fetch –all$ ~/ git merge origin/stage$ ~/ php bin/magento setup:di:compile-multi-tenant$ ~/ git commit –m “…”$ ~/ git tag v1.0.10$ ~/ (other misc…)

Deployment

(on branch production in repo)$ ~/ git fetch –all$ ~/ git checkout –b v1.0.10 v1.0.10$ ~/ php bin/magento module:enable <module01> <module02>$ ~/ php bin/magento setup:upgrade

Production Deployment

AutomationGit Hooks can automate deployment of code. Never hook a production deployment!

Deploybot can automate everything we’ve seen as well as static asset generation, etc.

Q A

Email: [email protected]

Twitter: @ryanstreet

Thank You