DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Cover image for Best Tools ๐Ÿ› ๏ธ for Different Coding Workflows
David
David

Posted on • Updated on • Originally published at bluecollardev.io

Best Tools ๐Ÿ› ๏ธ for Different Coding Workflows

When writing code I often find myself using different tools depending on the workflow I'm currently in.

In some workflows, like fixing a bug, understanding the code is most important. In other workflows, like implementing a new feature, my focus is more on writing code.

Here is an overview of my main workflows and which tools I use the most.

New Feature

When implementing a new feature, my focus lies on writing code. I want to write code as smooth and fast as possible and avoid distractions and context switching.

I use PhpStorm as my IDE. Since I'm already familiar with JetBrains IDEs and was not able to setup all the PHP plugins for vim correctly, I'm OK with it, although it's resource-intensive and could be a bit faster...

Of course, I'm using the IdeaVim plugin to make the editor feel more like home.

Also, I like PhpStorm's auto-completion and the database integration, which avoids another context-switch.

Because I'm using Laravel, I can usually generate whole files with the php artisan make command, and then fill in the methods:

$ php artisan make:controller CustomerController
Enter fullscreen mode Exit fullscreen mode

At our company, we customized the stubs so that the generated code complies with our coding standards.

For example, we always use strict typing in our code base. So we put declare(strict_types=1); at the top of the stub files.

Interconnected Feature or Change

A slightly different workflow is when I'm having to change an existing feature or add a feature, which has lots of dependencies to the rest of the code.

Then, my focus is a bit less on writing code and more on understanding existing code. For this, I use PhpStorm's "goto definition" and "find references" features.

Another tool, which we recently set up at our company is Sourcegraph. It's a search engine for code for your whole organization.

This tool was a game changer for us, because it makes understanding code, especially over different repositories, so much easier.

Another important part in this workflow play unit and feature tests. Luckily, we have a high tests coverage, so I'm constantly running the tests to see if my changes break something.

Thanks to paratest, Laravel can execute the tests in parallel, so this process is very fast.

Bug Fix

I find bug fixing a very different workflow. Writing code is less of a priority and understanding the code is key.

My favorite tool here is Sentry. It is extremely helpful for fixing bugs. Not only are you getting notified when an error occurs, but you also get detailed information about the environment and the inputs which lead to the problem.

After I'm having a good idea how I can reproduce the bug, I use Docker, Git and composer to set up my local environment to exactly mirror the production environment.

For debugging, I use PhpStorm's built-in debugger. The "Evaluate expression" feature (Alt+F8) is especially helpful.

I typically finish up with writing a test case which checks the bug fix.

Code Review

Code review is about understanding code, so I use the search features in PhpStorm and Sourcegraph a lot.

After I understand the pull request, I comment on it in BitBucket. BitBucket also shows the results from the pipelines, which runs the tests and linters.

I find the user interface of BitBucket pull requests slow and lacking in many ways, but haven't found a better way to do code reviews.

๐Ÿ‘‰ Which tools for code review can you recommend?

Architecture and Documentation

Another very different workflow is designing or architecting a new feature. During the actual work, I mostly resort to pen and paper.

To communicate my ideas afterwards, I draw diagrams in draw.io, describe them in markdown files or Word and present them in PowerPoint.

I also looked at Structurizr, but did not really start using it, because it is a bit more complicated and less flexible compared to draw.io.

๐Ÿ‘‰ Overall, it works, but I'm not super happy with the tools in this category. Can someone recommend better ones?

Top comments (5)

Collapse
arxeiss profile image
Pavel Kutรกฤ

php artisan tinker is super helpfull with functions like resolve() so you can try execute quite complex code easily.

I like Gitlab much more, and we migrated all repos from Bitbucket to Gitlab. But it is not perfect, on current project we use GitHub. All have pros and cons related to doing code review.

I'm also using custom set of rules for Code Sniffer (github.com/arxeiss/php-coding-stan...) based on Slevomat sniffs. This helps a lot. And also github.com/phpstan/phpstan

Collapse
davidrjenni profile image
David Author

php artisan tinker is super helpfull with functions like resolve() so you can try execute quite complex code easily.

Yes, php artisan tinker is definitively convenient and something I miss in other frameworks and languages I use.

I like Gitlab much more, and we migrated all repos from Bitbucket to Gitlab. But it is not perfect, on current project we use GitHub. All have pros and cons related to doing code review.

Thanks for the tip. I'll definitively try it out. ๐Ÿ‘

I'm also using custom set of rules for Code Sniffer (github.com/arxeiss/php-coding-stan...) based on Slevomat sniffs. This helps a lot. And also github.com/phpstan/phpstan

Funny, we use almost the same setup: phpstan and a custom ruleset for Code Sniffer, based on / including the Slevomat sniffs.

Collapse
arxeiss profile image
Pavel Kutรกฤ

About the tinker, did you check this? github.com/bobthecow/psysh/wiki/In... there are similar tools for other frameworks as well.

Thread Thread
davidrjenni profile image
David Author

No, I did not know about that. Thanks a lot for the pointer. ๐Ÿ‘

Collapse
davidrjenni profile image
David Author

Just found out about this PhpStorm plugin for php artisan tinker: plugins.jetbrains.com/plugin/14957....
If you are using PhpStorm, this might be a something for you.

๐ŸŒฑ DEV runs on 100% open source code known as Forem.

ย 
Contribute to the codebase or learn how to host your own.