43
Tools out of the box with Magento 2 in PHPSTORM

Tools out of the box with Magento 2 in PHPSTORM

Embed Size (px)

Citation preview

Page 1: Tools out of the box with Magento 2 in PHPSTORM

Tools out of the box

with Magento 2

in PHPSTORM

Page 2: Tools out of the box with Magento 2 in PHPSTORM

Hello!I am Andra LunguBitbull https://www.bitbull.it/

@iamspringerin

2

Page 3: Tools out of the box with Magento 2 in PHPSTORM

“ 3

Are you a rockstar?

And no, I am not asking if you’re in a rock band...

Page 4: Tools out of the box with Magento 2 in PHPSTORM

“ 4

Are you a rockstar?

Not me

Page 5: Tools out of the box with Magento 2 in PHPSTORM

“ 5

How many of you are new to

Magneto 2?

Page 6: Tools out of the box with Magento 2 in PHPSTORM

“ 6

I would hope everyone

But what about Magento 2 ?

Sorry, I consider myself funny but you can fake laugh

Page 7: Tools out of the box with Magento 2 in PHPSTORM

1.Composer

Dependency Manager

Page 8: Tools out of the box with Magento 2 in PHPSTORM

What is it for?

8

Page 9: Tools out of the box with Magento 2 in PHPSTORM

What is it for?Save you time

9

Page 10: Tools out of the box with Magento 2 in PHPSTORM

WithInstallation made easy

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2

10

Source http://devdocs.magento.com/guides/v2.2/install-gde/bk-install-guide.html

Page 11: Tools out of the box with Magento 2 in PHPSTORM

WithInstallation made easy

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2

curl -sS https://getcomposer.org/installer | phpmv composer.phar /usr/local/bin/composer

11

Source https://getcomposer.org/doc/00-intro.md

Page 12: Tools out of the box with Magento 2 in PHPSTORM

With

Installation made easycomposer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2

Update made easycomposer require magento/product-community-edition 2.1.9 --no-update

composer update

12

Source http://devdocs.magento.com/guides/v2.2/comp-mgr/cli/cli-upgrade.html

Page 13: Tools out of the box with Magento 2 in PHPSTORM

How Composer is exactly like…. a composer. In this case Magento 2 is a musical and the packages installed are the members of the orchestra. You can’t have a live

musical without the orchestra and you can’t have Magento 2 without its packages.

from digital agency Creare

13

Source https://magento.com/resources/harnessing-power-composer-magento-2

Page 14: Tools out of the box with Magento 2 in PHPSTORM

14

Source https://alankent.me/2013/10/19/magento-2-module-dependencies/

Page 15: Tools out of the box with Magento 2 in PHPSTORM

15

Source https://gordonlesti.com/magento-2-dependencywheel/

Page 16: Tools out of the box with Magento 2 in PHPSTORM

2.PHPUnit

Testing framework

Page 17: Tools out of the box with Magento 2 in PHPSTORM

What is it for?

17

Page 18: Tools out of the box with Magento 2 in PHPSTORM

What is it for?Save you time

18

Page 19: Tools out of the box with Magento 2 in PHPSTORM

How

With 4 minutes of your time( actually less but I am slow)

Tell PHPStorm where to find PHPUnit

{{magento_root}}/vendor/phpunit/phpunit/phpunit

19

Source http://devdocs.magento.com/guides/v2.2/test/unit/unit_test_execution_phpstorm.html

Page 20: Tools out of the box with Magento 2 in PHPSTORM

How

With 4 minutes of your time( actually less but I am slow)

Tell PHPStorm which configuration file to use

{{magento_root}}/dev/tests/unit/phpunit.xml.dist

20

Source http://devdocs.magento.com/guides/v2.2/test/unit/unit_test_execution_phpstorm.html

Page 21: Tools out of the box with Magento 2 in PHPSTORM

How

With 4 minutes of your time( actually less but I am slow)

Press the button Run all tests or run it from terminal

21

Source http://devdocs.magento.com/guides/v2.2/test/unit/unit_test_execution_phpstorm.html

php {{magento_root}}/vendor/phpunit/phpunit/phpunit --configuration {{magento_root}}/dev/tests/unit/phpunit.xml.dist

Page 22: Tools out of the box with Magento 2 in PHPSTORM

How

22

Source http://devdocs.magento.com/guides/v2.2/test/unit/unit_test_execution_phpstorm.html

After 4 + 2 of running tests

minutes of your time

Page 23: Tools out of the box with Magento 2 in PHPSTORM

With 1. Learning Magento 22. Bug Free code3. Bugfixing4. And avoid this….

23

Page 24: Tools out of the box with Magento 2 in PHPSTORM

Avoid

24

@note it's impossible to mock an order in Magento 1 * I can't ok? I give up, cost me 1 hour and still didn't get anywhere * So there you have it, I failed, happy now?! * If you're looking for me I'll be in a corner crying and wishing for Magento 2

Anonymous Source

Page 25: Tools out of the box with Magento 2 in PHPSTORM

3.PHPCS

PHP Code Sniffer

Page 26: Tools out of the box with Magento 2 in PHPSTORM

What is it for?Lose

Save you time

26

Page 27: Tools out of the box with Magento 2 in PHPSTORM

How

With 2 minutes of your time

Tell PHPStorm where to find PHPCodesniffer

{{magento_root}}/vendor/bin/phpcs

27

Source http://devdocs.magento.com/guides/v2.2/coding-standards/code-standard-sniffers.html

Page 28: Tools out of the box with Magento 2 in PHPSTORM

How

With 2 minutes of your time

Tell PHPStorm where to find ruleset.xml

{{magento_root}}/dev/tests/static/framework/Magento/

28

Source http://devdocs.magento.com/guides/v2.2/coding-standards/code-standard-sniffers.html

Page 29: Tools out of the box with Magento 2 in PHPSTORM

29

Page 30: Tools out of the box with Magento 2 in PHPSTORM

After 2 minutes of your timeYou’ll have your personal teacher and your pair programmer.

30

Source http://devdocs.magento.com/guides/v2.2/coding-standards/code-standard-sniffers.html

Page 31: Tools out of the box with Magento 2 in PHPSTORM

With1. Improve your knowledge of PHP2. Improve your coding style3. Enforce a standard inside your team4. Bugfixing

31

Page 32: Tools out of the box with Magento 2 in PHPSTORM

Quiz time

32

HEADERS ALREADY SENT

Anyone?( except Marius that is b*tching positively)

Page 33: Tools out of the box with Magento 2 in PHPSTORM

Quiz time

HEADERS ALREADY SENT

Anyone?PSR-2 2.2. Files

The closing ?> tag MUST be omitted from files containing only PHP.

33

Source http://www.php-fig.org/psr/psr-2/

Page 34: Tools out of the box with Magento 2 in PHPSTORM

34

Tabs VS Spaces

Anyone?( except Marius that is b*tching positively)

Source http://www.php-fig.org/psr/psr-2/

Quiz time

Page 35: Tools out of the box with Magento 2 in PHPSTORM

35

Tabs VS Spaces

Anyone?PSR-2 2.4. Indenting

Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting.

N.b.: helps to avoid problems with diffs, patches, history, and annotations.

Source http://www.php-fig.org/psr/psr-2/

Quiz time

Page 36: Tools out of the box with Magento 2 in PHPSTORM

4.PHPMD

PHP Mess Detector

Page 37: Tools out of the box with Magento 2 in PHPSTORM

How

With 2 minutes of your time

Tell PHPStorm where to find PHPMD

{{magento_root}}/vendor/bin/phpmd

37

Page 38: Tools out of the box with Magento 2 in PHPSTORM

How

With 2 minutes of your time

Tell PHPStorm where to find ruleset.xml

{{magento_root}}/dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/

38

Page 39: Tools out of the box with Magento 2 in PHPSTORM

39

Page 40: Tools out of the box with Magento 2 in PHPSTORM

After

40

After 2 minutes of your time Another teacher by your side

Page 41: Tools out of the box with Magento 2 in PHPSTORM

With 1. Cleaner code2. Easier to read3. Easier to refactor4. Better Performance

41

Page 42: Tools out of the box with Magento 2 in PHPSTORM

Each of us can be a rockstar,And why not, play in a rock band!

42

Page 43: Tools out of the box with Magento 2 in PHPSTORM

Thanks!Any questions? You can find me @iamspringerin & [email protected]

43