Access all articles in sprocket icon.
Published Ocotber 8, 2016 by Bill Keck.
Foundation Maker for Laravel 5.3 Officially Released
Foundation Maker is a free package for Laravel 5.3 that adds 15 new artisan commands, including make:foundation, which let’s you stand up an entire working CURD model and views, with an ajax-powered, searchable, sortable and paginated data grid, written in Vue.js.
Adding Foundation Maker to your Laravel project is a snap. Just use call the following on your command line:
composer require evercode1/foundation-maker
Then add the following to your providers array in config/app.php:
To see the new artisan commands, run the following from the command line:
php artisan list
Then you can parse through and see all the new make commands:
There’s also corresponding remove commands for all commands except make:assets.
Please note, if you are unfamiliar with Foundation Maker, read the docs and tutorial, and note that it works best with a fresh install of Laravel due to the setup of assets. Run npm install after running the make:assets command.
For those of you who have purchased my book, Laravel 5.3 For Beginners, you will recognize the data grid from the book. The big difference is that the book is written using Vue.js 1.0.26, and the Foundation Maker code generator uses Vue.js 2.0.1.
I will be adding a chapter to the book to introduce Foundation Maker and the migration to Vue.js 2, and that update will be free to everyone who has purchased the book. I will be emailing out an announcement when that is ready and then you will be able to pull the latest version of the book.
Previously, for Laravel 5.2, I created a different tool, View Maker, which got over 600 downloads on packagist.org. Creating View Maker was a lot of fun and I learned a lot. But instead of updating that tool, I decided to make a clean break, since the application structure of Laravel 5.3 is different, and Foundation Maker utilizes Elixir and the code it produces is actual production-level code. Foundation Maker is much more efficient and production-ready than View Maker was.
Foundation Maker also has some advanced features that View Maker does not. For example, you have the ability to make your own custom templates and have Foundation Maker use those templates instead of the native ones it ships with. This can be really handy if you want to setup your templates with your own style, which is probably going to be the way to do it most cases.
Let’s say for example, you want to setup your Foundation templates, so that the controller flashes an alert to the view when you create a new record. The native templates don’t have that for the obvious reason that not everyone might want it. Personally, I might use Sweet Alert for that, someone else may choose something else entirely. With the custom templates, you can decide which one to use and simply write it into the template, so every time you create a foundation, it is included automatically.
So you get complete control over the templates, and also, you get to inject custom tokens if you wish, which is another new advanced feature. The tokens get replaced into the template with the actual value of the token. For example, the :::model::: token would return Widget if Widget was the name of your model. You don’t have to worry about the model token, that one is baked in, but if you do have something you want that is not included in the native token list, then you can create your own, which is a very handy feature.
Although Foundation Maker is incredibly easy to use, I’m going to create a video tutorial series for it. I’m also going to be adding a lot more to it, so look for exciting announcements on that.
There are 2 ideas driving my development on Foundation Maker. One is that I want to use artisan commands to manipulate my templates. I like having the code where I would normally put it, instead of a vendor folder. Some of us already use our IDE to create templates. But while you could create templates through your IDE, you can’t really chain them together in the way that Foundation Maker can. When you run make:foundation with Foundation Maker, for example, with that one command, you are creating the following files:
- api controller (if it does not yet exist)
- unit test
- Queries folder (if it does not yet exist)
- GridQueries folder (if it does not yet exist)
- GridQueries/Contracts folder (if it does not yet exist)
- GridQuery.php (if it does not yet exist)
- DataQuery.php (if it does not yet exist)
- appropriately named model query file
- appropriately-named view folder
- index view
- create view
- edit view
- show view
- Vue.js component file
The make:foundation command also appends to the following files:
- ApiController (if it already exists)
That’s a lot of power wrapped up in one command. If you use the make:parent-child command, you get double that, one for both the parent and the child.
So the other idea driving my development on Foundation Maker is that I want to reduce the amount of time it takes to create an app. Laravel is an awesome framework, but there are still a lot of things you find yourself doing over and over that could be automated. Towards that end, I’ve only just begun. I want Foundation Maker to be able to help you stand up a full frontend, backend CRUD app in under an hour. It’s kind of a lofty goal, but that’s what I’m aiming for.
I have a lot of work ahead of me. I also plan to support Foundation Maker with free videos on how to use it, so keep an eye out for that announcement.
Thanks to everyone who has and is supporting my work. I don’t have a donate button, but if you would like to contribute, you may do so by buying one of my books, I would really appreciate it. Shares, comments, likes, and book reviews are also greatly appreciated. See you soon.