Merge remote-tracking branch 'jidbo/fix/typos'

This commit is contained in:
Saibotk 2023-11-26 16:50:54 +01:00
commit 506de0ebf1
Signed by: saibotk
GPG key ID: 67585F0065E261D5

View file

@ -9,16 +9,16 @@ pubDate: "Oct 13 2023"
## 🤔 Why?
There are many resources already available for setting up your PhpStorm. For example the excellent course from Jeffrey Way on [Laracasts](https://laracasts.com/series/phpstorm-for-laravel-developers), go watch it if you really want to make it your own!
There are many resources already available for setting up your PhpStorm. For example, the excellent course from Jeffrey Way on [Laracasts](https://laracasts.com/series/phpstorm-for-laravel-developers), go watch it if you really want to make it your own!
But this is much more a reference for random people on the internet, colleagues or friends on how i setup my PhpStorm and we will mainly focus on the Tooling setup in this post.
In the end I will also share some details on my color style customizations, where i will also share my customized Tokyo Night color scheme.
But this is much more a reference for random people on the internet, colleagues or friends on how I set up my PhpStorm, and we will mainly focus on the tooling setup in this post.
In the end I will also share some details on my color style customizations, where I will also share my customized Tokyo Night color scheme.
But why do you share this just now?
Mainly because I got inspired to be sharing more because of the amazing talk ["Publishing Your Work"](https://www.youtube.com/watch?v=2YaEtaXYVtI) from Aaron Francis.
Mainly because I got inspired to share more because of the amazing talk ["Publishing Your Work"](https://www.youtube.com/watch?v=2YaEtaXYVtI) from Aaron Francis.
Is this a perfect guide?
No, and it will never be. Everything in this world is changing really fast and if I would let my perfectionism decide wether or not to publish this, you would still only find the ol' "First Post" on my "blog".
No, and it will never be. Everything in this world is changing really fast and if I would let my perfectionism decide whether to publish this, you would still only find the ol' "First Post" on my "blog".
## 🔌 Plugins
@ -37,8 +37,8 @@ No, and it will never be. Everything in this world is changing really fast and i
To ensure safety in your PHP code, we want to enable PHPStan in the `PHP -> Quality Tools` section.
Make sure to adjust the level to a good default (will be overriden by your project's config anyways) and press the `...` button to properly set
a project independant path for PHPStan and fill in `./vendor/bin/phpstan`.
Make sure to adjust the level to a good default (will be overridden by your project's config anyway) and press the `...` button to properly set
a project independent path for PHPStan and fill in `./vendor/bin/phpstan`.
I honestly think JetBrains should just guess this automatically tbh.
@ -94,12 +94,12 @@ For JS files, lets setup the good ol' Prettier.
To do so, go to `Languages & Frameworks -> JavaScript -> Prettier` and enable `Automatic Prettier configuration`.
Now you can also adjust the file endings to include only some formats, but I changed it to check everything since this currently catches everything for my use case,
because it will run on all files in CI anyways and I often found myself to include more and more file endings.
because it will run on all files in CI anyway and I often found myself including more and more file endings.
So I just let Prettier check every file: `{**/*,*}.{*}`
Also remember to enable the `Run on save` checkbox for the auto fix on 💾 sweetness.
![The Language & Frameworks, JavaScript, Prettier settings screen with highlights to each option mentioned above.](../../images/setup-phpstorm-for-laravel-and-vue/format_prettier.png)
![The Language & Frameworks, JavaScript, Prettier settings screen with highlights for each option mentioned above.](../../images/setup-phpstorm-for-laravel-and-vue/format_prettier.png)
### ESLint
@ -107,7 +107,7 @@ Same thing for ESLint.
Go to `Languages & Frameworks -> JavaScript -> Code Quality Tools -> ESLint` and enable `Automatic ESLint configuration`.
For ESLint I still maintain a list of file endings, since it can get quite performance heavy.
Currently I have the following list: `{**/*,*}.{js,ts,mjs,cjs,mts,jsx,tsx,html,vue,astro}`.
Currently, I have the following list: `{**/*,*}.{js,ts,mjs,cjs,mts,jsx,tsx,html,vue,astro}`.
Again, remember to enable the `Run on save` checkbox for the auto fix on 💾 sweetness.
@ -115,19 +115,19 @@ Again, remember to enable the `Run on save` checkbox for the auto fix on 💾 sw
## Code Style
Now comes an important change to avoid conflicting code style formatting from PHPStorms rules, which need some tweaks since they are now active on save and usually people do not notice how the default settings look. If we do not change these, we will be able to see how PHPStorm first applies its own style and then runs tools like Laravel Pint which reformat the code again. For large files this could lead to big jitter and annoyance.
Now comes an important change to avoid conflicting code style formatting from PHPStorms rules, which need some tweaks since they are now active on save and usually people do not notice how the default settings look. If we do not change these, we will be able to see how PHPStorm first applies its own style and then runs tools like Laravel Pint which reformat the code again. For large files, this could lead to big jitter and annoyance.
Go to `Editor -> Code Style -> PHP`. Choose `Scheme: Default (IDE)`.
> Note: We do not use the `Set from...` Feature here, and instead configure only a handful rules on our own to match the style.
But we are not done yet, since the base configuration still formats way too much for my taste and maybe your colleagues. So we tweak some styles to avoid auto formatting code sections that are valid for Laravel Pint but not for PHPStorm. Our settings will reduce the impact of auto-formats to a minimum and ideally should not cause you to commit "unneccesary" styles which are not enforced through Laravel Pint for example.
But we are not done yet, since the base configuration still formats way too much for my taste and maybe your colleagues. So we tweak some styles to avoid auto formatting code sections that are valid for Laravel Pint but not for PHPStorm. Our settings will reduce the impact of auto-formats to a minimum and ideally should not cause you to commit "unneccessary" styles which are not enforced through Laravel Pint for example.
> If you have some custom Laravel Pint / PHPCsFixer rules and notice double reformats, you might need to match some settings to your rules.
### PHP Style Adjustments (config file)
You can now follow all of the steps below or just download my codestyle export and import it 😄
You can now follow all the steps below or just download my codestyle export and import it 😄
👉 Download the CodeStyle <a href="/phpstorm/PHPCodestyleSaibotk.xml" target="_blank">here</a>
And import it on the PHP Code style page, by clicking the ⚙️ icon.
@ -150,7 +150,7 @@ Change the `PHPDoc @param spaces` settings to 2.
#### Code Conversion
Now go to the `Code Conversion` tab and select `Lower case` for both `True/False` and `Null` constants.
Additionally enable `Convert else if/elseif to` and select `elseif`.
Additionally, enable `Convert else if/elseif to` and select `elseif`.
![A screenshot of the code conversion options.](../../images/setup-phpstorm-for-laravel-and-vue/style_code_conversion.png)
@ -177,11 +177,11 @@ Go to `Blank lines` and set `After namespace` to `1`.
For my IDE I chose the `Fira Code Nerd Font` which is a patched version of `Fira Code` with additional symbols used e.g. in my terminal.
It is set to size `15.0` with ligatures enabled, for extra fancy symbols.
For the terminal I am also using Fira Code, but this time the mono variant and in size `13.0`: `Fira Code Nerd Font Mono`.
For the terminal, I am also using Fira Code, but this time the mono variant and in size `13.0`: `Fira Code Nerd Font Mono`.
### Theme
As my theme I am using [Tokyo Night Dark](https://plugins.jetbrains.com/plugin/18820-tokyo-night-theme).
As my theme, I am using [Tokyo Night Dark](https://plugins.jetbrains.com/plugin/18820-tokyo-night-theme).
But I only use this as the overall editor theme, which can be found under `Appearance & Behavior -> Appearance`.
@ -189,11 +189,11 @@ But I only use this as the overall editor theme, which can be found under `Appea
![Screenshot of example code with my color scheme applied](../../images/setup-phpstorm-for-laravel-and-vue/color_scheme.png)
For the color scheme I decided to start with the [Tokyo Night Color Scheme](https://plugins.jetbrains.com/plugin/15662-tokyo-night-color-scheme) and then heavily modified it based on the original VSCode theme colors, to be more in line with the original theme.
For the color scheme, I decided to start with the [Tokyo Night Color Scheme](https://plugins.jetbrains.com/plugin/15662-tokyo-night-color-scheme) and then heavily modified it based on the original VSCode theme colors, to be more in line with the original theme.
Sadly though, I got to feel the inferior code color scheme options of PHPStorm in contrast to VSCode. Nonetheless it now looks pretty good and similar.
Sadly though, I got to feel the inferior code color scheme options of PHPStorm in contrast to VSCode. Nonetheless, it now looks pretty good and similar.
While not perfect, I uploaded my current version here and may upload it to the Marketplace if i ever feel like dedicating more time to it.
While not perfect, I uploaded my current version here and may upload it to the Marketplace if I ever feel like dedicating more time to it.
But for now I already invested way more hours into this than I initially wanted 😅
👉 Check it out <a href="/phpstorm/TokyoNightPlusPlus.icls" target="_blank">here</a>
@ -214,10 +214,10 @@ PHPStorm uses them for auto completion and I once made the mistake to exclude th
### Add Run Actions for Horizon etc
For projects using Laravel Horizon, I can only recommend to add this as a shortcut run configuration.
For projects using Laravel Horizon, I can only recommend adding this as a shortcut run configuration.
Go to `Run/Debug Configurations`, press `+` and add a new `Shell Script` command.
Set `Script text` to `php artisan horizon` or any other artisan command that is long running and uncheck the `Execute in terminal` checkbox.
Set `Script text` to `php artisan horizon` or any other artisan command that is long-running and uncheck the `Execute in terminal` checkbox.
Also make sure the `Allow multiple instances` checkbox is disabled.
![A screenshot of the Run/Debug configurations modal.](../../images/setup-phpstorm-for-laravel-and-vue/run_horizon.png)