ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Tools
out of the box
with
Magento 2
in
PHPSTORM
Hello!
I am Andra Lungu
Bitbull https://www.bitbull.it/
@iamspringerin
2
“ 3
Are you a rockstar?
And no, I am not asking if you’re in a rock
band...
“ 4
Are you a rockstar?
Not me
“ 5
How many of you are new to
Magneto 2?
“ 6
I would hope everyone
But what about Magento 2 ?
Sorry, I consider myself funny but you can fake laugh
1.
Composer
Dependency Manager
What is it for?
8
What is it for?
Save you time
9
With
Installation 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
With
Installation made easy
composer create-project
--repository-url=https://repo.magento.com/
magento/project-community-edition magento2
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
11
Source https://getcomposer.org/doc/00-intro.md
With
Installation made easy
composer create-project
--repository-url=https://repo.magento.com/
magento/project-community-edition magento2
Update made easy
composer 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
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
14
Source https://alankent.me/2013/10/19/magento-2-module-dependencies/
15
Source https://gordonlesti.com/magento-2-dependencywheel/
2.
PHPUnit
Testing framework
What is it for?
17
What is it for?
Save you time
18
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
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
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
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
With 1. Learning Magento 2
2. Bug Free code
3. Bugfixing
4. And avoid this….
23
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
3.
PHPCS
PHP Code Sniffer
What is it for?
Lose
Save you time
26
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
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
29
After 2 minutes of your time
You’ll have your personal teacher and your pair programmer.
30
Source http://devdocs.magento.com/guides/v2.2/coding-standards/code-standard-sniffers.html
With
1. Improve your knowledge of PHP
2. Improve your coding style
3. Enforce a standard inside your team
4. Bugfixing
31
Quiz
time
32
HEADERS ALREADY SENT
Anyone?
( except Marius that is b*tching positively)
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/
34
Tabs VS Spaces
Anyone?
( except Marius that is b*tching positively)
Source http://www.php-fig.org/psr/psr-2/
Quiz
time
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
4.
PHPMD
PHP Mess Detector
How
With 2 minutes of your time
Tell PHPStorm where to find PHPMD
{{magento_root}}/vendor/bin/phpmd
37
How
With 2 minutes of your time
Tell PHPStorm where to find ruleset.xml
{{magento_root}}/dev/tests/static/testsuite/Magento/Tes
t/Php/_files/phpmd/
38
39
After
40
After 2 minutes of your time
Another teacher by your side
With 1. Cleaner code
2. Easier to read
3. Easier to refactor
4. Better Performance
41
Each of us can be a rockstar,
And why not, play in a rock band!
42
Thanks!
Any questions?
You can find me @iamspringerin & andra.lungu@bitbull.it
43

More Related Content

Tools out of the box with Magento 2 in PHPSTORM