I Clicked Do Not Show Again in Phpstorm How to Undo This

What does it mean to be a good software programmer?

First, it requires deep knowledge of the particular tech stack you're working in. If you lot are a LAMP developer, you lot undoubtedly need to be an skilful in PHP and MySQL, know modernistic frameworks, and have some decent skills in Linux administration.

Second, but no less important, is working knowledge of the supplemental tools you apply everyday in your workflow.

You need to be able to piece of work properly with version control systems, continuous integration tools, virtual car management services (similar Vagrant) and, obviously, your integrated development environment (IDE).

This article covers the popular, robust IntelliJ IDEA IDE PhpStorm, and how, with a niggling effort, you tin easily double your efficiency and fifty-fifty foreclose bugs while you code.

Train Yourself with Keyboard Shortcuts

Let's start with the simplest and maybe the most important skill for whatever IDE: proper keyboard usage.

If you compare a seasoned programmer and an ordinary PC user, the first thing you'll notice is that the programmer spends nearly all of her time using a keyboard and hardly ever touches the mouse. In that location'southward a reason for that: It's much more efficient.

First, Become a Good Typist

While typing isn't connected directly to IDE skills, shortcuts are useless if you lot need to stare at your keyboard to detect every single central.

If you're not already typing at least 50 words per minute (WPM), find a touch typing grooming website such every bit TypingClub.com, and increment your speed.

There are also competitive typing websites, such as TypingRaces.com, where you can compete with other people in typing. My recommendation? Engage in a race as a morning warm-up each day.

Train Yourself To Use PhpStorm's Shortcuts

The fastest way to learn is to not give yourself an alternative to keyboard shortcuts.

When I was studying shortcuts, I turned off all menus, tabs, navigation bars, etc. You lot tin can practice it also by navigating to the View menu and unchecking all the marks (yous may want to leave the 'Status Bar'):

Unchecking the view menu items in PhpStorm.

My IDE at present looks like this:

A barebones IDE.

As you can see, I can't avoid using shortcuts, even if I wanted to.

Information technology took me almost three or four days of suffering to become by the laptop smashing stages of adjustment.

If you find your motivation flagging, PhpStorm has a born productivity guide. It contains a list of features and statistic of usage for each of them. Just click 'Help', and so 'Productivity Guide', and you lot'll run into something similar this:

The Productivity Menu

As you can see, shortcuts saved me from typing more than than 20,000 boosted characters (over the grade of six months) and prevented about ane,000 bugs. Pretty motivating!

It also tells me which features I'thousand not using very oftentimes, identifying places where I tin can improve my shortcut skills. Review your statistics, and utilise the cognition wisely.

Peak Keyboard Shortcuts

Jetbrains provides a handy PDF with all available shortcuts listed in its official documentation, and furthermore has a list of 'Keyboard Shortcuts Y'all Cannot Miss '. Start learning this immediately, until yous tin can do information technology in your sleep.

Past far, my favorite shortcuts are:

  • Ctrl+ E - toggle between recently used files
  • Ctrl + / - comment/uncomment a block of lawmaking
  • Ctrl + B - go to the grade declaration
  • Ctrl + North - navigate to course
  • Ctrl + R - search and replace
  • Ctrl +Alt + L - reformat code
  • Alt + Enter - bear witness intention actions and quick-fixes
  • Ctrl + Shift + Enter - complete statement

Some of these are self explanatory, others could use a fiddling more than coverage.

Switching Files with Ctrl + E and Enter

Imagine that you need to frequently switch betwixt two files, e.g. betwixt a PHP class with concern logic of your app and a template, which is used to return and output information technology.

Many developers would switch from the keyboard to the mouse, navigate to a tab with the file, click it, and find the needed part with a gyre bike. The problem: It's extremely slow!

Isn't it meliorate to just push button Ctrl+E and then Enter?

Ctrl+East volition testify you a list of recently used files, and if you immediately push button Enter, you'll be switched to the file used simply before the current ane.

You can use ctrl+e to switch between files.

If you want to go dorsum, just push button the same sequence once more.

Using ctrl+e to switch between files.

This is the fastest way to toggle between 2 files, with just three keystrokes! Just imagine how much time you'll salve, when y'all're having to do this hundreds of times per day.

Show Intention Actions and Quick-Fixes with Alt+Enter

Any modern IDE highlights errors and provides some suggestions for lawmaking improvement. If you move the cursor to whatever incomplete or undocumented slice of a lawmaking, you'll see a calorie-free bulb icon, and if you click on it, you lot'll run across a popup carte du jour of possible actions.

The same action tin be done by pressing Alt+Enter, which is much more convenient.

Alt+Enter shows you intention actions and quick fixes.

In the example on the screenshot above, PhpStorm offers two options: Add a PHPDoc specification to the part (which is a very good communication, stay tuned), and remove an unused parameter.

The same shortcut tin exist used for a lot of other mutual actions: creating getters and setters for class backdrop, initializing fields in constructors, adding undefined methods and properties, etc.

Complete Statements with Ctrl+Shift+Enter

This shortcut is very straightforward and extremely useful at the same fourth dimension, doing exactly what it says.

For instance, if you lot type $i = 0 and then printing Ctrl+Shift+Enter immediately after it, PhpStorm will add together a semicolon to your expression. If you type if and the shortcut after it, PhpStorm volition add brackets, and and then forth.

Use this shortcut as oftentimes as yous can. Information technology will relieve you a lot of time as all code consists of standard structures. Whatsoever speed increase in writing structures makes writing the code that much faster likewise!

The IdeaVim plugin

Using shortcuts tin drastically increment your productivity, but if it's not enough for you, the adjacent level is the IdeaVim plugin.

Equally you probably know, Vim is a panel text editor widely used by Linux geeks and devops' engineers, to administrate remote servers via the command line.

Vim has ii of import traits.

Starting time, information technology's hard to learn. Second, if you know information technology well, it pays off. Your productivity in text editing will get much better than with any GUI editor. There volition also be situations in your career when you take no choice just to use a console editor, like Vim, (if yous need to fix something on a remote spider web server and you lot have just panel access to it, for example).

But how is Vim related to PhpStorm?

Well, many developers want to combine Vim efficiency with features of a mod IDE (east.g. code completion, course search, advanced search and navigation). For that purpose the IdeaVim plugin was created.

Important notation: From here on out, I assume that you know the basics of Vim. If you don't, y'all can become started using Vim with vimtutor, which is accessible in almost all Linux distributions or openvim.

Plugin Installation

1. Navigate to 'File', then 'Settings', so 'Plugins' and blazon IdeaVim in the plugin search box. Mark the checkbox to the right of the plugin proper noun and click "Use". two. Restart PhpStorm. 3. Plow on the plugin via checking 'Tools' and then 'Vim Emulator'

Enable the Vim Emulator via the Tools menu.

4. Original PhpStorm shortcuts and Vim shortcuts (enabled by the plugin) can disharmonize with each other, and so you need to resolve these conflicts manually. Navigate to 'File', 'Settings', 'Other Settings', then 'Vim Emulation'. You'll see the list of conflicting shortcuts. In this listing, you can choose whether to use the PhpStorm shortcut or the Vim shortcut spring to that key sequence. You tin come across my current choices in the screenshot below. If you lot tin't make a conclusion, only leave a shortcut undefined; PhpStorm volition ask you to choose when you utilise information technology for the first time.

There will be some shortcut conflicts between PhpStorm and the Vim Emulator, but you can choose which to use.

Plugin Usage

After you turn on the plugin, you'll immediately detect that the editing area becomes similar to Vim:

  • The cursor changed its form and became rectangular, similar in Vim.
  • If y'all try to type something in the editor, cypher volition happen.

From this point, y'all can start editing your files exactly similar you lot would practise information technology in Vim, using the h, j ,k, l keys for navigation, and the i key for switching between normal way and insert mode, etc.

Virtually all Vim shortcuts are supported by the plugin.

Simultaneously, all of the IDE features are still present, then y'all tin can edit the text extremely fast, using just your keyboard (like in Vim), and still spring between classes, files, usages and definitions (like in a PhpStorm modern workflow).

One of the best advantages of whatever IDE over ordinary text editors is the ability to implement an advanced search.

It may seem redundant, if you have worked merely with small projects, simply when you outset working with a large codebase, with complicated OOP relations between classes, y'all will understand how indispensable it is.

It's easy to find a particular string in a file by common search (Ctrl + F) or search-and-supersede (Ctrl + R), but what if y'all need to find a definition of a particular class in thousands of files? Or if yous want to find a detail method in a class containing thousands of lines of lawmaking? Or perhaps you desire to exclude all comments from the retrieval results? That'southward where a mod IDE like PhpStorm helps.

In this department, I'll show you the most useful variants of search in PhpStorm.

Find in Path

Afterward the ordinary search, the easiest search is for a particular string in all files in some subfolder of the project. It's so easily implemented in PhpStorm that I utilize it much more frequently than any other search options.

For example, search for usages of a course User in my example app.

ane. Push Ctrl + Shift + F. You lot'll see a popup window with Search options. Blazon 'User' in the query string. You'll see a number of results in a Preview tab:

A basic ctrl+shift+f search.

2. Now, we can switch to the Preview tab, and manually find needed results in that location, but we have more 100 matches. Deadening! Let'south be more specific.

First of all, we're searching for the class usages, so let's check the "whole words but" choice. It volition help us to avoid results like E_USER_ERROR.

Side by side, let's exclude searching in comments and string literals, and limit our results by .php files only.

It also sometimes makes sense to specify a more concrete subfolder of the project. In this instance, all project-specific code is situated in the app folder.

So allow'south modify the scope directory to example-app/app.

Now, we have a search window like this one:

A more refined find in path search.

Simply by being more specific in our search parameters, nosotros've decreased the number of results from hundreds to only 24!

At present, it's very easy to examine each of them manually. Moreover, we don't fifty-fifty need to open each file separately considering we accept a very convenient preview tab:

The find in path search results preview tab.

In everyday practice, the notice in path search covers about 80 pct of all searches I make. It's so useful that even if y'all utilise nil else for your retrievals, you'll still be pretty efficient.

Go to Declaration

Another extremely important ability of PhpStorm (every bit with all mod IDEs) is to jump between usages and declarations of classes and functions.

Allow's assume we have a function, which creates a new User. Obviously, we do not recall all methods and properties of the User form, so we demand to examine the declaration of the class to decide how to perform all needed deportment. In that location are several ways to practice information technology.

First, you lot can open a class declaration as a quick read-simply popup window.

Simply move your cursor to any class usage and push button Ctrl + Shift + I. The read-simply window will appear:

Get a read-only preview with Ctrl+shift+I.

You lot can examine all necessary data, and return back to the initial file. It'south extremely quick; y'all don't even need to switch between files!

But, every bit I mentioned, the popup window is read-only, and so if you decided to change something in the User class while examining it, you'll demand some other shortcut: Ctrl + Shift + B.

This navigates you lot directly to the form. When you make your changes, you can easily return to the initial file, using Ctrl + East, Enter sequence we covered before.

List All Methods of the Current Grade

The terminal variant of the search functionality, which I use everyday is 'search by grade structure'. Sometimes PHP classes are very long, and it's difficult to find a particular property or method.

If yous push Ctrl + F12 while the class file is open, you'll see a popup window with a construction of the class:

Pushing ctrl+f12 will open a pop up with the file structure of the opened class file.

If y'all begin typing the method proper name, y'all'll see only the methods matching the pattern you typed:

If you start typing a method name, such as 'get', you'll only see matching methods in the ctrl+f12 pop up.

Just imagine that you lot take about 100 methods (which is not a skillful practice, but you may run across such code), and y'all need to frequently switch between two of them. It tin can make y'all crazy using ordinary search!

Past using the file structure search instead, every switch will take virtually five keystrokes. Just type Ctrl + F12, start typing the name of the desired method, press Enter, and you'll get to its declaration.

By the style, Ctrl + F12 is not a convenient shortcut, so you may want to consider irresolute information technology to something else. Personally, I use Alt + R.

There are many more search methods in PhpStorm, just these 3 can cover almost all everyday search tasks.

A Epitomize on Searching Functionalities

  • If yous need to search something found in multiple files, use the observe in path search (Ctrl + Shift + F), and try to brand search options (filtering) as specific equally you can.
  • If you demand to quickly encounter the source of a course or a method, employ Ctrl + Shift + I and examine information technology via the quick popup window (if you need to edit information technology, navigate to the declaration via Ctrl + Shift + B instead).
  • If you have a large form and need to inspect its structure or quickly switch betwixt methods, use a file structure shortcut, Ctrl + F12 past default.

Live Templates Usage for All Basic Language Structures

While shortcuts allow you lot to write and navigate lawmaking fast, at that place is a way to meliorate it even more – autocompletion and live templates.

Basic autocompletion is pretty easy, and you should certainly know about it.

If you start typing a name of a class, method, or variable, whatsoever skilful IDE will testify you lot a list of possible endings. Y'all can choose any of them, and avoid typing upwardly to the finish.

Basic autocompletion.

That said, you can go much farther with live templates.

In this section, you'll learn which alive templates I use in my everyday work. I split them into 3 groups: basic language constructions, functions with long names, and HTML chunks.

Basic Language Constructions

Needless to say, developers use standard language constructions, like while, for, foreach, if many times per twenty-four hour period, so it's extremely inefficient to type them from scratch every fourth dimension. That's why there are built-in alive templates for them in PhpStorm.

For some life-changing live template magic, open up PhpStorm, and type forek in the editing surface area, and press Enter. You'll see this:

The 'forek' live template.

PhpStorm substituted a template with a consummate foreach cycle and prepared stubs for all necessary variables. Yous just need to fill in correct variable names.

If yous press Ctrl + J, you'll see the list of currently supported live templates, applicable for the current place of the code. You can cull any of them.

Ctrl+j brings up a list of live templates.

As you may have noticed, some very frequent constructions are missing hither. For example, I always miss a live template for the while bicycle, so permit's create it!

Navigate to 'Settings', then 'Editor', then 'Live Templates', choose 'PHP', and click on the green '+' at the right-acme of the popup window:

You can add new templates by going to Settings, then Editor, then Live Templates.

Fill out the 'abbreviation' field with 'wh', and the 'description' field with 'while(bool_expr){…}'. The 'template text' field should take the following:

          while($EXPR$)  {     $END$ }                  

Click the 'define' link beneath the 'template text' textarea and choose 'PHP' from the list, so information technology knows in what context to use this template.

At present, let's discuss how information technology works.

When yous type wh, Enter in your editing area, it will be substituted with the template text.

The cursor will exist moved to the first template variable, $EXPR$ in our case, then you can type whatsoever expression (e.m. $i > 0) and press Enter again.

After that, the cursor will exist moved to the next variable (nosotros only have one in this case), and so on. $Stop$ is a special variable that denotes the place where the cursor should movement after all variables are filled.

Nosotros have only 1 variable, so information technology will exist moved to the $Stop$ correct after we fill $EXPR$, and we'll be ready to input a cycle body.

Create your own live templates for all language constructions that you ofttimes apply. It'due south much better to invest some time upfront than to spend it everyday on typing such constructions from scratch.

PHP Functions

Unfortunately, PHP has a reputation of a language with long and inconsistent role names.

The good news it that you can substitute them with short abbreviations using live templates. For example, if you desire to properly check if some central exists in an array, y'all demand to call the part array_key_exists($my_key, $my_array).

Information technology's extremely tedious to type it every time even with standard autocompletion, and so just create live templates for all such cases.

Personally, I prefer 'ake' for array_key_exists, you can choose any other. Here's how to create the 'ake' live template:

Screenshot of the author's array_key_exists template.

HTML chunks

Last, but certainly not the least popular usage of live templates, is handling HTML chunks.

If you're not already using live templates, I bet you've been doing a lot of irksome (and basically, useless) work, creating standard HTML markup elements. Live templates change that by doing what we've done above but with the 'template text' field being your HTML.

Avoid Bugs with PHPDocs

And so far, you've learned PhpStorm efficiency tips and tricks, but expect, there'due south more than. Efficiency is non the only area where it can assistance, information technology can likewise help avoid bugs, even before the starting time run of your program.

Out of the box, PhpStorm tells you about obvious errors.

For example, if you lot take forgotten a semicolon afterward a statement, information technology will mark it cherry, but that functionality is trivial, so I'll not describe it.

What's interesting is when PhpStorm tells you most much more complex bugs, when you give it the information information technology needs to via PHPDocs.

Ideally, PHPDoc specifications is mandatory on your team for all methods and made as rigorous equally possible. Consider an case with our User form once again. Assume we have a office, which returns an assortment of User objects:

An array of user objects.

By default it's not documented, and then other developers may not know the blazon of the returned value and may apply it improperly.

For example, some other developer wants to recollect a list of usernames. For some reason, she thinks, that the User object has a getName() method. Merely in reality it doesn't, then the developer makes a mistake:

In this example, the user class doesn't have a getName() method.

PhpStorm doesn't treat this is as a issues because information technology knows nothing about the $user variable. So it stays unnoticed, and we end upwardly with a very nasty error.

The offset selection is to only plough on strict typing, which became possible in PHP7, but let'south assume we can't do that for some reason. Maybe we are working with legacy lawmaking. In this case, PhpStorm volition help united states, if we let information technology.

For this to work, you'll need to generate a PHPDoc for every function. Information technology's commonly considered a good habit, and it will help you to avoid bugs, become along with fellow developers, and fifty-fifty pass interviews in which employers examine your source lawmaking.

To generate a PHPDoc, movement the cursor to the name of the part, press Alt + Enter, option the item "Generate PHPDoc for role" in the popup menu, and printing Enter once more.

Alt+enter gives the option to generate a PHPDoc for the function.

The basic PHPDoc template will appear:

The basic PHPDoc template for our User class.

You can meet PhpStorm guessed that the returning value is an assortment, but it couldn't guess that information technology's an array of User objects, and then permit's explicitly stipulate this past changing 'array' to read 'User[]' instead:

Updated PHPDoc to offer User[] as the return value.

At present that nosotros've told PhpStorm what it needs to know about the method, let's return to the getUserNames() method call:

Now that the PHPDocs are defined, we can see that getUserNames() is invalid.

Now that PhpStorm tin parse the PHPDoc return type declaration, it tin can signal us to the error and even hint as to what exactly is wrong. PhpStorm, in combination with PHPDocs, can brand PHP a very rigorous language! An astonishing outcome!

PhpStorm is not Just for PHP Developers

While all the topics covered centre on PHP development, PhpStorm is based on a very powerful IntelliJ Platform, making it possible to utilise with various languages, frameworks, and tech stacks, that are far from the PHP earth.

Front-end evolution

Even if you are a dorsum-stop developer, you'll need to solve some front-end issues from time-to-time. Information technology tin can be a unproblematic fix in HTML markup, calculation a parameter to the REST client, written on AngularJS, etc. The proficient news is that all of that can be done in PhpStorm.

The basic rule of thumb is: Check if information technology's supported out of the box. If not, try to notice a plugin.

For case, Javascript, CSS, and pop CSS preprocessors, like LESS and SASS, are supported out of the box. AngularJS support is hands added as a plugin (installation path is the same every bit for IdeaVim plugin). With this mindset, you'll be able to solve nigh all possible front-end tasks.

Working with Databases

Typically, application databases are managed via command line or special tools, similar MySQL Workbench, just PhpStorm can help you lot here too.

Just click Database on the right margin of your screen, and you'll see a list of available databases (initially empty) and a query window, which has autocompletion, like the common editing area, making it very convenient.

PhpStorm supports almost all modern databases. MySQL, PostgreSQL, Oracle Database, and SQLite are supported out of the box, while MongoDB is supported via plugin installation.

Hateful stack

The terminal and the near amazing not-PHP example is MEAN stack development.

Mean stands for MongoDB, ExpressJS, AngularJS, Node.js.

It'south a trending tech stack, being used merely about everywhere. It'due south very fast and extremely expert for fast, lightweight web-services.

Even as a PHP developer, I sometimes create Node.js services as supplemental tools for PHP projects (eastward.k. websocket services, unproblematic chatbot back-ends, etc).

As you probably guessed, all components of the MEAN stack are supported in PhpStorm, so whenever you demand to create a MEAN stack project, keep in mind that y'all don't need another IDE. PhpStorm will do the job perfectly.

The Power of PhpStorm is in Your Hands

Using the power of PhpStorm and the fundamental skillsets covered in this article, you too can increase your efficiency and prevent bugs before you lot even finish typing.

hillyouted.blogspot.com

Source: https://www.toptal.com/php/how-to-be-efficient-in-phpstorm

0 Response to "I Clicked Do Not Show Again in Phpstorm How to Undo This"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel