Source: medium.com

Laravel Custom File Stubs

Category: Laravel, Laravel, PHP, PHP, api, api

There is the feature of Stubs Customization in Laravel in which you are free to modify the stubs files that are generated when you run php artisan vendor:publish. While in this tutorial we are going to create our own starter template that is defined on our own custom stub files from scratch.

The gist of this console command magic is to get the content of the stub file intereface.stuband change the stub variable of the file i.e. $NAMESPACE$ and $CLASS_NAME$ with the user-defined value and place it in the desired path in your project.

Add the getStubVariables function that will map the stub variable present in the stub file (interface.stub) mentioned above to its value In the return array above, the key NAMESPACE and CLASS_NAME are the stub variable (placeholder) present in the stub file with their respective value to replace the placeholder.
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