it's okay it's only two minutes I'm
probably gonna go 10 minutes over just
just so you know
welcome to maximum phpstorm if you
haven't heard this talk before I've
given it a couple of other times you'll
be able to find it in it's longer form
on Drupal to be just search for maximum
phpstorm there and you'll see a couple
versions of this talk you'll see how
it's been iterating for this talk I've
had to kind of blow up my whole strategy
of how I'm going to be going through
this I'm gonna build in some extra time
at the end because when I've done this
so there's been a lot of people who also
know a lot of things about things back
there so we're going to go through
things that you know how to do with your
tools
so just in while we're going through
queue that up in your mind
also you may see at the top of the
slides here there is a link that you can
go if you want to submit your question
textually we'll be referencing that at
different points in presentation mainly
at the end and like I said I could talk
about this for days but before we get
too into the weeds let me introduce
myself my name is Chris Weber I am a
nerd at the nerdery software engineer
and phpstorm enthusiast you can find me
on drupal.org as cosmic dreams and
Twitter as Chris sim Weber I've been
using a phpstorm for a long time but I
didn't start my career there when I
started as a developer I worked a lot
with visual studio I taught myself how
to use work with net MVC used that skill
to start a company with a buddy of mine
and we did dotnet and Drupal for a good
number of years until we decided to part
ways but every bit of skill that I ever
learned about dotnet I had to
my own and it was because of the
wonderful support that Visual Studio
provides it's a overwhelmingly complex
tool and it was way too powerful for me
when I first started but they had had a
great tutorials in great documentation
online and I was able to fight my way
through of my uncertainty and confusion
to have a professional skill and when I
shifted back to Drupal work because I
was doing Drupal way before I ever
touched any line of net
I often felt overwhelmed by the
complexity I felt powerless because all
I really had at the time was a text
editor and everything I knew about how
to solve problems I had to either fight
on drupal.org through searches with the
API documentation through searches or
just in my head there is nothing that
the tool could really do to help me I
had to do it myself
and so I firmly believe and you can
debate me on this feel like but I firmly
believe that tools like Visual Studio
and phpstorm while being overly complex
and can be overwhelming at times they
can do a lot to ramp up your skill as a
developer from being that confused and
uncertain developer that needs to know
everything and just the the competent
and confident developer that is able to
offload some of the responsibility of
knowing all the things to their tools so
that's the journey we're going to be
going through today we're gonna walk
through the journey of a developer and
and how a tool that is complex like
phpstorm
can help you through many different
stages these are kind of the stages that
I went through becoming more comfortable
as a professional developer how to
discover details and in facts and
figures about your code things that can
prevent to save you from the the
frustration or shortcut the amount of
time that you take in order to work
through things we'll do a little bit of
work with the digital detective work
that we do on a daily basis the work to
discover facts about what's going on in
your code right at this moment and then
how to adapt the tool
because if you have to be forced to
adopt the thinking and the ways of
working of a specific tool that's never
going to work for anybody you've got to
make the tool work for you but before we
dive into that I just want to put
because I feel very strongly about this
I am I do not want for you to take away
from this talk that you have to switch
from the tool that you love do using the
tool that I love if you love any of
these tools if there's a tool up here
that you love that isn't up here feel
free to use that what I'm really trying
to communicate today is that these are
things I've found in phpstorm and
they're found in many other different
places so if this specific technique
that I'm talking about is available in
your tool or if there are there are like
dark places and weird parts of your tool
you have yet to explore I encourage you
to explore those and use those because
knowing your tools deeply and being
comfortable your tool is the main thing
that will get you from the two
confidence
okay let's begin
discovering your tool modern tools like
phpstorm
try to index all the code that you give
it so that when you need it they can
assist you with remembering the names of
objects functions everything about that
is inside your code so here's a few ways
that phpstorm can discover facts about
your code modern tools lots of tools if
you don't have a tool that has
intellisense consider using a different
tool I just said to use the tool that
you love but I mean come on if you can't
have a tool that is able to tell you the
things that are in your code and force
you to like manually look up things that
okay let's let's just let's just set the
level there it must have the ability to
give you answers about your code
intellisense is a great first step so
that work that it does to index all of
your code this is where it pays off
being able to like search for the name
of a variable and and then methods or
anything that's in your code phpstorm in
particular is quite famous for its shift
shift search for everything everywhere
function you can search for classes and
methods and functions or even things
that aren't in your code
things like preferences within your
administrative preferences you can
search for that all in one place and
often when you're searching for the name
of a thing all those search results are
confounded together so you may think
you're looking for an object but in the
end what you really want to define is a
function you'll get that all in one
place
I took thought I deleted that slide and
I thought ideally that's it
they didn't know there are more targeted
searches you can do if you want to
search for the name of a specific file
or a class or a method there are
specific keyboard shortcuts you can do
and they're there any windows people in
the room this is for you I've lots of
these presentations forget to include
the windows shortcuts the these
shortcuts are valid for both windows and
linux and so I will endeavour to include
those so yeah if you want to search for
a specific thing you can do that and
here is where my talk branches so I like
to fly by the seat of my pants
how about today we do something
completely different
what I'm suggesting that we should do in
the next couple minutes is let's go
through a couple of things if you've got
specific things you're gonna feel oh I'm
going to this demo let me add that in
but what we're going to do here is we're
going to audit a module that we grabbed
just off of drupal.org we're going to
check it for code formatting violations
we're going to fix anything we find and
we're going to make a issue back to the
module and contribute that code live
alright so this worked before a split
screens
so the biggest thing we have to make
sure here is that you can see this text
can you see this text before I really
get going is it too big is it too small
thumbs up okay all right ah good let me
minimize that for now if I can there's
the mouse okay so one of the my favorite
things to do these days is to check
modules for quote formatting violations
it's a great way to contribute back work
and it's something that people who work
on modules absolutely hate to do they're
just trying to fix things and make new
stuff they don't want to make sure that
everything is coaching so I go to
Twitter and I go to a Twitter user
called Drupal 8 modules and I just
search for that and I grab one and I fix
it
that's what oh that's why I did not
minimize his temp so here's a Drupal 8
modules today and I was just scanning
through it and then I found I guess it
updated a little bit Oh focal point I
like focal point that's a great little
module let's do that one
so we navigate to that module and what
we want to do is in order to if we find
something we're going to fix it we want
to contribute it back so we can't just
you know download the module what we
really want to do is we want to get the
source code so we go on over whoops to
virtual control a version control
automatically selects the Drupal seven
one we want the triple-eight one and so
we do that and then we grab this line
this is hella hard dudes
do it do it there we go copy that
all right P start go to the command line
it's the mouse there there's the mouse
mr. Mouse
there's a mouse there's the mouse all
right go to the command line
Here I am
all right Oh I created the tap there we
go
so here I am in my open source directory
where I put all the things that I'm
grabbing that I'm working on the open
source and I'm just going to paste that
command let's go get it
boom there it is and then we'll go up to
phpstorm and we'll open that there we go
all right so here I am and there should
be an open source directory there it is
area and then over here should be a
fixed focal point there it is found it
okay super interesting folks all right
so you know as since we opened a Drupal
engaged the the drupal integration we'll
turn that on and then we'll have to
enable it we'll have to tell it that
it's true Drupal 8 module and then it's
just a module it's not all of Drupal so
we have to tell it where the rest of
Drupal is good news I've got that
already
so there's Drupal 8.5 I know I should
update it
I think it's connected to composure so
maybe it is up-to-date who knows
alright so I told it that there's more
than I need to do it told me that it can
help me some more I can make sure that
the Drupal code formatting settings are
set so I'm gonna set that all right so
by this time hopefully it's almost done
scanning
cool so it is alright so here's the
trick that no one will tell you we want
to scan this for code formatting
violations but the best way to do that
with modern Drupal projects is to use
PHP code significant so you can search
your preferences for code sniffer and
then you'll able to like find the PHP
code sniffer integration here and you
just want to turn that on but you want
to give a little bit extra help so
you'll turn on show the specific sniff
that violates you want to trick it into
saving the configuration here yeah yeah
these are default plugins yep and then
when you click OK you'll be able to save
a weird configuration file here so
now when you look inside the the secret
folder that it creates called the idea
folder there's a folder in there called
inspector Pro class so what you want to
do is you want to edit that one file
that's in there and just tell it to use
both the Drupal and the Drupal practice
code formatting standards like that
that's that escape there's escape
okay refresh your settings and now when
you exits the Preferences it should say
Drupal and Drupal practice yes okay
now we're good to go all we have to do
is run a code sniffer on everything and
have it tell us what we need to do it is
something I have to do once I'm out of
the text the console there we go we're
gonna run some code sniffer we're gonna
run it on everything and looks like it's
going to include JavaScript and CSS
files and I guess it's fine
just ignore those so it's going to run
the analyzer and it's going to round on
a whole bunch of things and what was the
key board short
the keyboard shortcut for running any
individual code inspection on the screen
which it should have showed you on the
screen I guess is shown on my screen is
a shift command option I holla at the
end there'll be a cheat sheet of all the
keyboard shortcuts that we're using
today okay
so let's fix something all right well
there's a test there's a widget let's
fix the widget numerical strings only
strings
literals should be passed that sounds
fun there's a lot of those Oh Oh
expected new line that's an easy one
okay so that one says there was one new
line is found
I expected what I didn't find one yeah
I'm really regretting not marrying the
screen
Oh drupal calls should be avoided we're
not going to be fixing that one
it's another new line
they'd open til my screen
but this week warning mean like I don't
know it's just not a big deal letter
yeah well we intentionally told it that
everything that it finds doing the code
sniffer should be classified as a week
warning so we told it to do that
but I thought this was gonna be I
thought I found a whole bunch of stuff
that was earlier today I hope they
didn't fix everything fix the things you
have yeah thanks guys
well alright for a lack of better time
let's just say that we were able to fix
this by breaking up this specific line
all right so we've got a change here so
what I did was I basically highlighted
the line and then I pressed option
command L to format the line based upon
its now it's the rules that it knows now
about Drupal's code standards and
because phpstorm has git integration I'm
able to open up git and see the file
that I've modified and then I'm very
press command D on the changed file in
order to see a window that popped up for
me on my screen and it looks like it
didn't actually change the thing we
intended to change but instead like
reformatted the the order in which
things happen but for the sake of time
let's just go through the process of
like if if we had properly fixed that
how would we convert that into a patch
that we can submit in order to do that I
would suggest the best thing to do would
be to go back to the command line which
is it here in the terminal and then you
can do a git diff in order to see that
change and then what we're going to do
is we're going to export this diff into
a file so we can submit it and probably
the best thing to do in order to get
that accomplished is to go on over to
the issue and make sure that we can see
where the mouse is and make sure that we
actually create an issue for this
create a new issue
so formatting demo
we fixed some code formatting during
mid-game
the reason why I create the issue ahead
of time is so that I can get a an issue
number I'm definitely not seeing that oh
there it is a that should be a point X
I don't know what I just clicked up
here we go say that
and grab that number so that over in
phpstorm
when we export this gif this diff we can
use the number so that the file that you
upload is referencing the issue that
you're creating and now that we've got
the file
and just upload it to the issue
what was the answer that's another thing
I do I try to make sure that every patch
I upload refers to the comment within
the issue that I'm doing it so since I
know that it's going to create comment
one and just saying that hey I created
this issue
I knew that comet two was going to be
the the issue that I'm gonna be
uploading it to
I definitely can't see that but you
would find the file wait Kenzi oh but
see I'm still kind of new to max and
then open source
focal point and there it should be there
it is
there you go
so that's the process all right back to
the show
all right cool time and frustration
savers we just looked a little bit about
cleaning up code there are a couple of
commands that I like to use
there's the reef app format code
function you can do shift alt and and
shift command L in order to format code
based upon the default settings or
settings that you apply for just that
particular reformatting a little video
live and that time to show it if you are
working with a bit of code you need to
update the documentation block above the
code you can press option enter and then
it will automatically generate a dock
block for the bit of code that you're
working on it's and that's one I've
learned recently
yes yeah yeah like if you wanted to
update that block if if like you've
added a new parameter to your function
and you want to make sure that it just
stubs out what it what it can about that
function you're gonna add details like
what data type that new parameter is but
yeah it works another kind of cool thing
that always is overlooked that you know
Drupal knows a lot about the I mean a
phpstorm knows a lot about the Drupal
API if you've highlighted a function you
want to search that function in the
triple API you can do that yeah okay
that's that's what you say yeah that
works too
another thing I like to do which we just
turned on I just showed you how to turn
on for the project is to just leave the
PHP code sniffers scanning you know
phpstorm has tons of other inspections
to just keep them on so that passively
scans your code and it catches like
stupid mistakes like missing a comma or
tabbing something wrong and you're able
to see both in the code that you're
currently looking at the specific
violation but a little squiggly the line
that shows in a Nathan you're also able
to see it like everything that it thinks
that could possibly be wrong in your
document by what's showing up on the
right bowling lane whatever it's going
the file health check this is this is
what I did earlier when I just wanted to
run a specific inspection URLs also able
to run this to run all inspections on
the current file that you're working on
this is a good way of like while you're
working through a thing you're able to
see hey did I screw something up in the
process your board or has this
particular file been so out of
compliance with coding standards that we
need to have a conversation you're gonna
do this you're able to get a health
check on a specific file scratch pads I
once worked with a developer that would
not use any tool without a scratch pad a
scratch pad is a temporary file that is
not saved on your machine but it's full
access to everything your ID knows and
can do so it's just this little place
you could throw stuff you just copied
from somewhere and reformat it there
before you want to put it in because
maybe you have accidentally have had a
history of like pasting things from the
web and not reformatting things and
people have told you not to do that just
saying oh this might be a good
opportunity to play a little video
okay so here I wanted to
create a little module
and I believe when I did this demo I
didn't realize that I had this named
this file it needs to be the same name
as the folder is made oh no this is
where I'm demoing the Drupal integration
the Drupal integration not only knows
about how to access the API but it knows
about every hook that is in an existence
so if you create a module file you're
going to start typing the name of the
the hook you want like there I type
altar here I'm typing free crosses it
automatically knows to put the name of
the module ahead in the hook spot of the
hook and then to put the dock block in
place that you're supposed to be putting
so the years still in compliance with
code standards thank you
we've got five minutes I've got more
slides don't really care about them I
care about what you want to know because
I could ramble but I don't want to make
I don't want to play a gif over and over
again
I must have clicked it that's why so
let's jump in what do you want to know
about or is there anything you want to
share with you about how you use be to
be smarter so I noticed you've just seen
about the terminal
yes and only we thought not to be bad
and it's just something I'm not aware of
but I tried it but that it didn't have a
complete yes you have that that's
correct
how do you do that well I make sure the
terminal is using the same terminal that
I use when I use a terminal oh I've got
a Mac this is different on Windows
Windows people right so whole windows
you have to like tell it specifically
what terminal you need to use and what
arguments that want to sit the
appropriate way it's a mad science on
Windows Mac it's really easy
you can't you just tell it just figure
out what man is want to terminal and you
teach terminal and phpstorm how to do
the same thing let's jump in
so in phpstorm every night at any point
when you're in phpstorm you can press
command comma in order to get into the
preferences and then you can just start
typing so terminal and this used to work
terminal
terminal that's not my are you we only
sing yeah this used to be a thing that
was first kind of shoes in my oh oh I
did see that you can't really see well
oh and it typed it there - hey terminal
high terminal and so the current command
the current start directory that he's is
there the current fire mantle is use
there the current shell path in order to
launch your terminals there if you don't
like batch like something else you can
tell it which one you want to use and
then yeah other kind of preferences they
recently added within this year they
added the ability for the terminal
inside phpstorm to remember how many
tabs you had opened and what you named
them so if you are antsy about that you
think not that to those might be a
little more advanced but is it possible
associate like a Lando container Orlando
your projects of like it'll spin it up
when you open your project and spin it
down so maybe not the Rube Goldberg you
just described but phpstorm does have
docker compatibility and I've used it in
the past it works really good so maybe
as I've never used land of myself maybe
the way you use lando is to launch
everything via the command line and
maybe what you want is just some kind of
way to kick that off real quick
but maybe you launch the specific Ducker
instances individually or maybe you like
have some kind of bootstrapping instance
and so the dr. integration in phpstorm
would be good for the second option and
Mainland the terminal that's in phpstorm
would be good for the first time
yes
yeah you know like when you open like a
PHP extension just like from your email
attachment let's just say and then your
Mac is like oh girl Graham do you want
to open this in and use form and I
always say remember this well when you
first install PHP stormer when you
install an update you're able to declare
that you want to install the command
line level launcher P store and so you
could from a terminal type via storm and
then the name of the file and PHP
strongwood installed with that file open
but that's not a problem I ever
encounter because every time I'm working
on a thing it's like I downloaded the
entirety of repository and as soon as I
opened that get repository in phpstorm
it knows like where I left off what tabs
I had open you know did I have the
terminal open or not do they move things
around the the screen I'm sorry I really
wanted to show that like how to make
phpstorm be the way that you like to
work maybe I could just tangent into
that then want to do so here in the
Preferences you can just hit escape and
then it's out but every one of these
tabs like the version control tab we're
still in focal point right so I'm able
to see like the entire git log and it's
this really long list so maybe I don't
want it like right underneath there
maybe I want it on the right and so
should be able to do this is a gear
right yeah and then I'm able to say move
to the right move to a kid
where's right bottom
boom there now it's on the right so I
can see this big long list and sure it's
much did everything but the point is
every one of these panels every one of
these tabs can be moved around to where
you want it to be and as soon as you
close be a star remember where you put
them used to be above a couple years ago
where forgotten they fixed it
so remember everything are the
Preferences project-specific so if you
open up a different project will it yep
there are project specific settings
recently they added an ability to make
those specific configuration files able
to be committed to a code repository so
there are some things you want to share
on developers to do that but for every
project every project is is completely
different but I do like to have as you
can see here yeah doctor and there is
nothing that I have to watch instances
any other questions any other tip it's
you know misnomer you'd like to share
with her
sometimes I open up a PHP file and it
doesn't know that it's a Drupal yeah
well if it's just a PHP file it really
has no context to note this is a Drupal
PHP 500 but if you were to open a thing
that looks like a Drupal module there's
a good chance that it will recognize
that it's a Drupal module and then ask
you if you want to turn on the Drupal
extension so you can always go to the
Preferences and manually turn the the
Drupal extension on so you just go to
preferences and then you just start
typing Drupal and then boom you'll be
able to go to this framework section
they tuck it away in there now and
they're able to check enable Drupal
integration you're able to tell it what
first from the Drupal everything that we
just did
but thing to do with phpstorm is like to
you know do dips between like my version
and like a certain branch I like and
then maybe bring over a change from a
branch or like well that's great I also
like that but yeah I I know I'm gonna
use get from the command line up I just
desperately don't want to especially
when it comes to things that are super
annoying like rebasing
and one of the things that is so great
about beauty storm is that they have a
three-way merge we're able to go through
an entire list of everything that is
conflicting in a rebase and you're able
to say well I don't care about that but
I do care about this I'm gonna do you
only would have great confidence that
you're not further blowing things up
three bases can be scary sometimes
yeah but also the history is is really
great because you get you get a view of
all the all the branches that is an
operation
oh I guess not anymore we got to see
whoo take a little screen all the
branches that are related and then at
any point in time you're able to see the
difference between that moments and time
in your current code that whenever
something goes wrong those are the main
skills to apply did anyone notice that
there's also really advanced filters so
if you wanted to find out everything
that you committed to the repository you
can search for yourself if you think
someone it specifically messes something
up you search specifically for that you
search for a specific time frame it's
something blow up recently these are the
kind of detective skills that would have
talked about that we could have gotten
into I should have had faith that we
would bet their burden any PHP storm
question together
okay anybody got anything one of my
newspaper you got a pic do you have a
link to your slides with
some things yes but probably the best
way to do that is to find one of my
previous talks on Drupal Duck TV okay
yep we've compiled every slide I had I
had all set keyboard shortcuts for Mac
and Windows
hours oh one of my favorite things one
of my favorite things that I've recently
learned about in phpstorm
is that they've added the ability to
debug twit templates so if you're
working on a Drupal 8 project the
standard mode of operation for most
critical projects is to turn all the
twit caching off and to get all the twig
debug messaging on the screen I would
suggest that you can still continue to
have all the debug messaging on the
screen that the wonderful informative
HTML code comments that tell you exactly
what surrendering when you see a thing
but go ahead and be brave and turn that
twit cash back on because if you can
jump into the Preferences you can now go
and search for or quick and you're able
to tell it that you want to set the cash
patch and that cash path will most
likely be in your site's default files
PHP folder that's where everything that
Drupal is caching PHP lies so there'll
be a twig folder that's in there you
just put that here and then after that
you can put a breakpoint in any twig
cloud that aides say it's not working
fine right now
I've had to manually compile the twig
templates in order for jumbles show up
at all because apparently the way that I
set up projects I have fundamentally
broken the ability for witty TP cash so
I've had to manually tell the site to
create those to be addressed but what do
you do that you said that there you're
able to break point into twig and you're
able to navigate to it you get a lot of
the same information you would get
through other means like if I don't know
if everyone's for the module tweak tweak
it's a good way or use kids to yeah okay
I know okay bye oh well thank you all
for going on this journey with me I hope
you find my other talks at triple dot TV
if you have any feedback you want to
give me about this talk and how I can
make it better please come to tell me
directly I love feedback or you can
tweet me it like Chris and Webber
apparently people to sharing these links
but nobody gave one to me I don't know
how you can give other feedback other
than send it to me still didn't see it
there I looked yeah thank you
so it should be there now Oh