https://media.notthebee.com/articles/66140cebd8f8d66140cebd8f8e.jpg
Oh man I absolutely love this.
Not the Bee
Just another WordPress site
https://media.notthebee.com/articles/66140cebd8f8d66140cebd8f8e.jpg
Oh man I absolutely love this.
Not the Bee
https://picperf.io/https://laravelnews.s3.amazonaws.com/featured-images/featured-img-laravel-news-2.png
Call it age. Call it apathy, if you must. I call it contentment. Much of my twenties were spent endlessly experimenting and searching for the perfect editor and workflow. As I read these words back to myself, Iâm somewhat embarrassed. âReally? Thatâs what you spent your twenties doing?â Okay, well, not exclusively. I also like hiking. But, yes, if a new editor hit the market, I was first in line to test it out.
But that was a long time ago. Fast-forward to 2024, and I canât remember the last time I installed a new code editor. In my eyes, PhpStorm won the IDE wars years ago. The quality and power that theyâve managed to bake into one application is truly staggering.
So, in that spirit, Iâd love to share my setup and general workflow with you. As youâll soon see, the term IDE no longer suggests an incredibly dense UI with hundreds of buttons (though thatâs an option, if you prefer). No, I prefer a more minimal approach that I think youâll appreciate. Okay, letâs do this!
When it comes to color themes, it has taken me a decade to realize that one of your IDEâs suggested defaults is usually the way to go. A plugin containing hundreds of themes, each of which misses the mark in some key area, isnât a great experience. But your editorâs default themes have been battle tested in every possible configuration.
With that in mind, my preference these days is PhpStormâs Dark theme, combined with their âNew UIâ (now the default layout).
Similarly, I also stick with the default JetBrains Mono font at 15px
. Yes, it seems that age is becoming a recurring theme for this article. Fifteen pixels looks good to me now.
Youâll notice that Iâve also hidden line numbers and tabs. This is of course a personal preference – and a questionable one to many – however, itâs worth experimenting with for a day.
If youâd like to test it out, like all of PhpStormâs various actions, you can toggle line numbers and tabs using the âSearch Anywhereâ menu, which defaults to a keybinding of âShift + Shift.â Search for âline numbersâ and âtab placement,â respectively.
For file traversal, I use a combination of the âSearch Anywhereâ and âRecent Filesâ menus. Even better, because all of PhpStormâs file trees allow for instant filtering, I only need to open the âRecent Filesâ menu and begin typing the first few characters of the file that I want to open. Itâs an incredibly fast workflow.
When it comes to plugins, the truth is that PhpStorm includes most of what you need straight out of the box. Support for Tailwind CSS, Vue, Pest, Vite, and Node – to name a small handful – are bundled from the start.
As a former Vim user who will never abandon the keybindings that I spent over a year drilling into my finger tips, I do pull in IdeaVim, which is effectively a Vim engine. And if you want to play around with custom UIs and themes, consider installing the Material Theme UI, Nord or Carbon plugins.
But – thereâs one incredibly important plugin that deserves its own headingâŚ
PhpStorm has a secret weapon that Iâve yet to see any competing editor match. Laravel Idea is a cheap third-party plugin (with a free 30 day trial) that provides an incredibly deep understanding of the Laravel framework.
It provides powerful code generation directly from your editor, Eloquent attribute auto-completion, pre-populated validation rules, smart routing completion, and so much more. Laravel Idea is the only plugin I pay for, and I do it without thinking. Itâs that good.
Of course, Laravel and Artisan provide a variety of generators that can be triggered from the command line. However, if you prefer, you can instead run these generators directly within PhpStorm. Navigate to the âLaravelâ tab in the menu bar, and choose âCode Generation.â
Here, you can choose your desired file type to generate. Itâs so fast.
Notably, when generating an Eloquent model, youâll be introduced to a dedicated dialog for configuring your desired fields, relations, and options.
Here, I can declare all of the appropriate fields for the model and toggle any companion files that should be generated in the process.
Letâs see another example. Imagine that you have an endpoint in your routes file that stores a new Job
in the database. Certainly, you should first validate the request data. Rather than writing the rules manually, Laravel Idea can do it for you.
Route::post('/jobs', function () {
request()->validate([
//
]);
});
Place the caret within the validate()
array, press Cmd + n, and choose âAdd Eloquent Model Fields.â Type the name of the relevant model, Job
, and the plugin will populate the array with the appropriate rules, like so:
Route::post('/jobs', function () {
request()->validate([
'employer_id' => ['required', 'exists:employers'],
'title' => ['required'],
'salary' => ['required'],
]);
});
Useful! Laravel Idea provides countless time-savers just like this. Itâs an essential plugin for every Laravel user, in my opinion.
The best argument for a dedicated IDE is that you want an editor that deeply understands your underlying language. If I need to rename a variable, implement an interface, or extract a method, I donât want to rely on regular expressions or a third-party extension. I want that functionality baked into the editor. I want these things working properly to be directly correlated to the financial success of Jetbrains.
If youâre anything like me, you probably have keyboard shortcuts seeping out of your ears at this point. Itâs incredible that we can remember so many across a wide range of apps. With that in mind, while there are respective shortcuts for each of PhpStormâs refactoring options, I use the catch-all âRefactor Thisâ menu, which I bind to Ctrl + t. Open âSearch Anywhereâ and type âRefactor Thisâ to open the menu manually. This will display a top-level refactoring menu, at which point I can select my preferred refactor.
As always, begin typing to instantly filter the menu items. If I need to, say, extract a method, I would type âextractâ and press enter. That way, I never have to reach for the mouse.
Beginning with the 2024 edition of PHPStorm, youâll find a new integrated terminal UI thatâs significantly improved over previous iterations.
It now supports auto completion, command history (press up), isolated command blocks, and more. Iâd recommend binding the integrated Terminal to a shortcut that youâll remember – I prefer "Ctrl + ` (Backtick)" or Now, you can rapidly toggle the terminal without ever leaving your editor.
Testing in PhpStorm is a breeze. Whether you prefer PHPUnit or Pest, it has you covered. Open any test class or file, and youâll find a Run icon beside each test definition. Give it a click to run that single test in isolation directly inside your editor.
Of course, not every test will pass. For this reason, it can often be useful to re-run the last test from anywhere in your project. This way, you can open a class, make a change, and instantly re-run the failing test to confirm that the issue has been resolved.
The command you want for this behavior is âRerun.â To avoid touching the mouse, consider assigning a keybinding, such as âShift + Command + T.â
Tip: You can configure your own keybindings within Settings â Keymap.
In the screenshot above, notice that the commented-out line in Comment.php
has triggered a failing test. Letâs fix the issue by uncommenting that line (if only all bugs were this easy to solve), and rerunning the test (using Shift + Command + T).
Wew!
PhpStorm of course includes support for automatic code formatting in a variety of code styles. Within the Settings menu, visit Editor â Code Style â PHP and click âSet Fromâ to choose your style.
This is helpful, but if youâd instead prefer an external code formatter such as Laravel Pint, you can easily instruct PhpStorm to disable its internal formatter in favor of your external tool. This is precisely what I do.
Open your Settings menu once again, and visit PHP â Quality Tools. Here, youâll find a handful of external formatters. Select âLaravel Pintâ and you should be all set to go!
Next, it would be nice if we could instruct PhpStorm to perform a series of actions or commands each time we save a file. For example, format the file, optimize the imports (sort and remove unused), clean up the code, run ESLint, etc. This is what the âActions on Saveâ menu is for. You can access it within the Settings menu, as usual: Tools â Actions on Save.
Select your preferred actions, and the editor will execute them each time you save a file.
Despite what its creator may suggest – đ – Xdebug can often be an exercise in frustration to install. Itâs clear, though, that the PhpStorm team is well aware of this. Theyâve done an excellent job making the process as simple and obvious as possible. Let me show you.
The first stop on your debugging journey is Settings â PHP â Debug. On this page, youâll see a âPre-Configurationâ checklist to verify that youâve properly installed Xdebug. Helpful!
This checklist roughly consists of installing Xdebug, choosing a browser toolbar extension, enabling listening for PHP Debug Connections, and then starting a debug session. I would highly suggest using the validator that PhpStorm links to in pre-configuration step one.
Validation Heads Up! If youâre using Herd Pro to automatically detect and enable Xdebug on the fly, PhpStormâs configuration validator will fail if you simply copy the contents of
phpinfo()
directly from the command line (php âinfo | pbcopy
). Instead, signal to Herd that you intend to use Xdebug. One way to do this is by setting a breakpoint. Click inside the gutter for any line number. Next, echophpinfo()
and copy its output directly from the browser.
Once you follow each step in the pre-configuration checklist, you should be ready to roll. Set a breakpoint, load the page, and start debugging like the champion you are.
And thatâs a wrap!
You may have noticed, but programmers tend to have⌠opinions. When it comes to code editors, they have even more opinions. Of course, choose the tool that best fits your personality and workflow, but I really do think PhpStorm is worth your time. Having used it for many years at this point, I continue to discover new features and time-savers that I never knew existed.
If Iâve piqued your interest, we have an excellent and free PhpStorm course over at Laracasts. In 2.5 hours, weâll show you everything you need to know. đ
The post Jeffrey Way’s PhpStorm Setup in 2024 appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.
Laravel News
https://picperf.io/https://laravelnews.s3.amazonaws.com/featured-images/featured-img-laravel-news-2.png
Call it age. Call it apathy, if you must. I call it contentment. Much of my twenties were spent endlessly experimenting and searching for the perfect editor and workflow. As I read these words back to myself, Iâm somewhat embarrassed. âReally? Thatâs what you spent your twenties doing?â Okay, well, not exclusively. I also like hiking. But, yes, if a new editor hit the market, I was first in line to test it out.
But that was a long time ago. Fast-forward to 2024, and I canât remember the last time I installed a new code editor. In my eyes, PhpStorm won the IDE wars years ago. The quality and power that theyâve managed to bake into one application is truly staggering.
So, in that spirit, Iâd love to share my setup and general workflow with you. As youâll soon see, the term IDE no longer suggests an incredibly dense UI with hundreds of buttons (though thatâs an option, if you prefer). No, I prefer a more minimal approach that I think youâll appreciate. Okay, letâs do this!
When it comes to color themes, it has taken me a decade to realize that one of your IDEâs suggested defaults is usually the way to go. A plugin containing hundreds of themes, each of which misses the mark in some key area, isnât a great experience. But your editorâs default themes have been battle tested in every possible configuration.
With that in mind, my preference these days is PhpStormâs Dark theme, combined with their âNew UIâ (now the default layout).
Similarly, I also stick with the default JetBrains Mono font at 15px
. Yes, it seems that age is becoming a recurring theme for this article. Fifteen pixels looks good to me now.
Youâll notice that Iâve also hidden line numbers and tabs. This is of course a personal preference – and a questionable one to many – however, itâs worth experimenting with for a day.
If youâd like to test it out, like all of PhpStormâs various actions, you can toggle line numbers and tabs using the âSearch Anywhereâ menu, which defaults to a keybinding of âShift + Shift.â Search for âline numbersâ and âtab placement,â respectively.
For file traversal, I use a combination of the âSearch Anywhereâ and âRecent Filesâ menus. Even better, because all of PhpStormâs file trees allow for instant filtering, I only need to open the âRecent Filesâ menu and begin typing the first few characters of the file that I want to open. Itâs an incredibly fast workflow.
When it comes to plugins, the truth is that PhpStorm includes most of what you need straight out of the box. Support for Tailwind CSS, Vue, Pest, Vite, and Node – to name a small handful – are bundled from the start.
As a former Vim user who will never abandon the keybindings that I spent over a year drilling into my finger tips, I do pull in IdeaVim, which is effectively a Vim engine. And if you want to play around with custom UIs and themes, consider installing the Material Theme UI, Nord or Carbon plugins.
But – thereâs one incredibly important plugin that deserves its own headingâŚ
PhpStorm has a secret weapon that Iâve yet to see any competing editor match. Laravel Idea is a cheap third-party plugin (with a free 30 day trial) that provides an incredibly deep understanding of the Laravel framework.
It provides powerful code generation directly from your editor, Eloquent attribute auto-completion, pre-populated validation rules, smart routing completion, and so much more. Laravel Idea is the only plugin I pay for, and I do it without thinking. Itâs that good.
Of course, Laravel and Artisan provide a variety of generators that can be triggered from the command line. However, if you prefer, you can instead run these generators directly within PhpStorm. Navigate to the âLaravelâ tab in the menu bar, and choose âCode Generation.â
Here, you can choose your desired file type to generate. Itâs so fast.
Notably, when generating an Eloquent model, youâll be introduced to a dedicated dialog for configuring your desired fields, relations, and options.
Here, I can declare all of the appropriate fields for the model and toggle any companion files that should be generated in the process.
Letâs see another example. Imagine that you have an endpoint in your routes file that stores a new Job
in the database. Certainly, you should first validate the request data. Rather than writing the rules manually, Laravel Idea can do it for you.
Route::post('/jobs', function () {
request()->validate([
//
]);
});
Place the caret within the validate()
array, press Cmd + n, and choose âAdd Eloquent Model Fields.â Type the name of the relevant model, Job
, and the plugin will populate the array with the appropriate rules, like so:
Route::post('/jobs', function () {
request()->validate([
'employer_id' => ['required', 'exists:employers'],
'title' => ['required'],
'salary' => ['required'],
]);
});
Useful! Laravel Idea provides countless time-savers just like this. Itâs an essential plugin for every Laravel user, in my opinion.
The best argument for a dedicated IDE is that you want an editor that deeply understands your underlying language. If I need to rename a variable, implement an interface, or extract a method, I donât want to rely on regular expressions or a third-party extension. I want that functionality baked into the editor. I want these things working properly to be directly correlated to the financial success of Jetbrains.
If youâre anything like me, you probably have keyboard shortcuts seeping out of your ears at this point. Itâs incredible that we can remember so many across a wide range of apps. With that in mind, while there are respective shortcuts for each of PhpStormâs refactoring options, I use the catch-all âRefactor Thisâ menu, which I bind to Ctrl + t. Open âSearch Anywhereâ and type âRefactor Thisâ to open the menu manually. This will display a top-level refactoring menu, at which point I can select my preferred refactor.
As always, begin typing to instantly filter the menu items. If I need to, say, extract a method, I would type âextractâ and press enter. That way, I never have to reach for the mouse.
Beginning with the 2024 edition of PHPStorm, youâll find a new integrated terminal UI thatâs significantly improved over previous iterations.
It now supports auto completion, command history (press up), isolated command blocks, and more. Iâd recommend binding the integrated Terminal to a shortcut that youâll remember – I prefer "Ctrl + ` (Backtick)" or Now, you can rapidly toggle the terminal without ever leaving your editor.
Testing in PhpStorm is a breeze. Whether you prefer PHPUnit or Pest, it has you covered. Open any test class or file, and youâll find a Run icon beside each test definition. Give it a click to run that single test in isolation directly inside your editor.
Of course, not every test will pass. For this reason, it can often be useful to re-run the last test from anywhere in your project. This way, you can open a class, make a change, and instantly re-run the failing test to confirm that the issue has been resolved.
The command you want for this behavior is âRerun.â To avoid touching the mouse, consider assigning a keybinding, such as âShift + Command + T.â
Tip: You can configure your own keybindings within Settings â Keymap.
In the screenshot above, notice that the commented-out line in Comment.php
has triggered a failing test. Letâs fix the issue by uncommenting that line (if only all bugs were this easy to solve), and rerunning the test (using Shift + Command + T).
Wew!
PhpStorm of course includes support for automatic code formatting in a variety of code styles. Within the Settings menu, visit Editor â Code Style â PHP and click âSet Fromâ to choose your style.
This is helpful, but if youâd instead prefer an external code formatter such as Laravel Pint, you can easily instruct PhpStorm to disable its internal formatter in favor of your external tool. This is precisely what I do.
Open your Settings menu once again, and visit PHP â Quality Tools. Here, youâll find a handful of external formatters. Select âLaravel Pintâ and you should be all set to go!
Next, it would be nice if we could instruct PhpStorm to perform a series of actions or commands each time we save a file. For example, format the file, optimize the imports (sort and remove unused), clean up the code, run ESLint, etc. This is what the âActions on Saveâ menu is for. You can access it within the Settings menu, as usual: Tools â Actions on Save.
Select your preferred actions, and the editor will execute them each time you save a file.
Despite what its creator may suggest – đ – Xdebug can often be an exercise in frustration to install. Itâs clear, though, that the PhpStorm team is well aware of this. Theyâve done an excellent job making the process as simple and obvious as possible. Let me show you.
The first stop on your debugging journey is Settings â PHP â Debug. On this page, youâll see a âPre-Configurationâ checklist to verify that youâve properly installed Xdebug. Helpful!
This checklist roughly consists of installing Xdebug, choosing a browser toolbar extension, enabling listening for PHP Debug Connections, and then starting a debug session. I would highly suggest using the validator that PhpStorm links to in pre-configuration step one.
Validation Heads Up! If youâre using Herd Pro to automatically detect and enable Xdebug on the fly, PhpStormâs configuration validator will fail if you simply copy the contents of
phpinfo()
directly from the command line (php âinfo | pbcopy
). Instead, signal to Herd that you intend to use Xdebug. One way to do this is by setting a breakpoint. Click inside the gutter for any line number. Next, echophpinfo()
and copy its output directly from the browser.
Once you follow each step in the pre-configuration checklist, you should be ready to roll. Set a breakpoint, load the page, and start debugging like the champion you are.
And thatâs a wrap!
You may have noticed, but programmers tend to have⌠opinions. When it comes to code editors, they have even more opinions. Of course, choose the tool that best fits your personality and workflow, but I really do think PhpStorm is worth your time. Having used it for many years at this point, I continue to discover new features and time-savers that I never knew existed.
If Iâve piqued your interest, we have an excellent and free PhpStorm course over at Laracasts. In 2.5 hours, weâll show you everything you need to know. đ
The post Jeffrey Way’s PhpStorm Setup in 2024 appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.
Laravel News