Source: guilhermenascimento.medium.com

Teeny.js, a route system for Node.js

Category: Laravel, PHP, nodejs

I came across many suggestions for implementing the php artisan serve command in Lumen, however sometimes in development, especially with the popularization of microservices, that is, there may be situations where different applications need to communicate, usually in a development environment using only ports as access. So starting application by application with php -S host:port -t public can be a little tricky or just annoying. Fortunately if we have the value of APP_URL in env we can facilitate part of the process. First create a file called ServeCommand.php in the ./app/Console/Commands/ folder, after edit app/Console/Kernel.php and put ServerCommand, like this: The class Illuminate\Console\Command has a protected method called getOptions(), with it we can define default values for parameters in a command, or also inform if a parameter is optional (Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL) or required (Symfony\Component\Console\Input\InputArgument::REQUIRED).

The proposal is to use as an option, that is, allow the user to change the host or port if desired when entering a command, or else use the value of APP_URL.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners