My Laravel Development Environment

Photo by Ben Allan on Unsplash

My Laravel Development Environment

·

3 min read

In Laravel applications, we use dd() to dump data, or Log::debug() to write debugging messages to log files. These are pretty handy functions. However, do you know there are other tools that can help you? These tools can help you to improve the efficiency of debugging.

In this article, I'd like to share how I set up my typical work environment, including what software and packages I use, and how I use them.

Software I use

Laravel Valet

It may surprise many people that I use Valet rather than use docker. While using docker can ensure that your development environment consisted of your co-workers', Valet is often faster and it is reliable enough.

But, isn't Valet macOS only? What if I don't own a Mac? You can use Valet on Linux! There is a community-maintained [Valet for Linux](https://cpriego.github.io/valet-linux/) That I always use on my Linux machine.

Once installed Valet, starting to develop a new Laravel project is like a no-brainer, just cd to your project folder and use valet link --secure, and you can access your site in seconds.

Did you notice that I added --secure flag? Yes, I use HTTPS on my local machine while developing. And you should do it too! Using Valet makes setting up HTTPS sites a lot easier.

Dash

Dash is a documentation viewer on macOS. With Dash, you can quickly search lookup documentation on a certain PHP function, or view a page of Laravel's documentation.

Packages that I use in every Laravel project

barryvdh/laravel-ide-helper

Laravel uses many traits of PHP's dynamic nature. I know many people hate it. But I think it is a trade-off that makes development a lot easier. You just need to use it with caution.

One of the downsides of using these dynamic features is that it lacks IDE support. For example, PHPStorm won't understand Facade calls by default. Those static method calls are dynamically forwarded to the underlying instance that is resolved by the IoC container. The ide-helper packages provided a workaround for this.

laravel/telescope and fruitcake/laravel-telescope-toolbar

Laravel Telescope is Laravel's first-party package that provides a debugging and monitoring tool for web applications. It allows developers to view detailed information about their requests, events, models, and more. Telescope can be used to inspect and debug requests, view database queries and their execution times, and monitor application performance. Additionally, Telescope provides insights into queue jobs, scheduled tasks, exceptions, and more.

With Telescope, you can easily inspect incoming requests, see what data is passed to your application, and view detailed information about exceptions and errors. No more need to dd() your $request in controllers!

laravel-telescope-toolbar is a package that provides a convenient way to access Telescope from your browser. The package adds a beautiful toolbar with quick links to the Telescope dashboard, request logs, and other sections.

pestphp/pest

PEST provides a lightweight, expressive, and test-oriented way to write PHP tests. It is built on top of PHPUnit, and provides a quick and easy way to write tests without having to learn the full PHPUnit API. PEST also makes it easier to write tests by providing helper functions and assertions.

If you are new to TDD, I suggest you to giving PEST a try. It is fast, easy to learn, and has a great community of developers.