Lambo "config" and "after" scripts for even better quick Laravel app creation
Posted on July 22, 2017 | By Matt Stauffer
If you're not familiar with Lambo, it's a command-line tool I built to quickly spin up a new Laravel application and take some of the most common steps you may want to at the beginning of each project. Check out our writeup on the Tighten blog if you want to learn more.
I use Lambo all the time. I create a lot of apps, yes, but I also write and teach about Laravel a lot. Before Lambo, I would hack my examples and tests into a pre-existing app to make sure things worked the way I wanted. With Lambo, I now just spin up a quick new Laravel install every time I need to test anything. I love Lambo.
I love the customization flags you can pass into Lambo. "I want to open the code in Sublime Text, the site in Chrome, and I want to run
npm install afterward." Cool.
But the switches are hard to remember; and, honestly, it's harder to remember to even type them.
lambo MyApplication -e subl -q imconfused -zztop... more often than not I type
lambo MyApplication and then two seconds later yell "crap" and CMD-c and try to re-do it with the right flags. At that point, Lambo's still faster than not-Lambo, but it's starting to bother me.
And, of course, there are still some common tasks that you could never perform with Lambo—for example, installing your use-on-every-app packages.
So, I made an issue. I had some discussion with folks who take a look at Lambo's issues, and we came up with the idea of a config file that lets you set your defaults.
Thanks to @_cpb, you can create a
config file (which lives in
~/.lambo/config) that's a
.env-style set of key/value pairs. Each key represents one of the variables that is toggled by one of the command-line flags. This way, you do't have to remember to always set your code editor; just set it once in
config and it sticks.
Just upgrade to the latest (
composer global update tightenco/lambo) and then create a config file (
lambo make-config). Here's mine:
#!/usr/bin/env bash PROJECTPATH="." MESSAGE="Initial commit." DEVELOP=false AUTH=false NODE=true CODEEDITOR=subl BROWSER="" LINK=false
Edit that file and its flags will be passed to every new application you create with Lambo.
That covers you for remembering the config flags. But what about other operations you take every time you spin up a site?
We have you covered for that, too. Once again, I opened up an issue, we had some conversation, and a different contributer @quickliketurtle wrote the actual code. You can now create an
after script (
~/.lambo/after), a shell script that runs after Lambo's normal processes, and you can define literally anything you want in there.
Here's what mine looks like:
#!/usr/bin/env bash # Install additional composer dependencies echo "Installing Composer Dependencies" composer require barryvdh/laravel-debugbar # Copy standard files from ~/.lambo/includes into every new project echo "Copying Include Files" cp -R ~/.lambo/includes/ $PROJECTPATH # Add a git commit after given modifications echo "Committing after modifications to Git" git add . git commit -am "Initialize Composer dependencies and additional files."
Just like with the config file, upgrade Lambo (
composer global update tightenco/lambo) and then create an
after file (
lambo make-after). Edit that file and it will run every time after Lambo runs.
I put a
nitpick.json file in that
includes/ directory so my Nitpick config is set up right on every project I start.
Now it's easier than ever to use Lambo to spin up the perfect Laravel application, every time.
Comments? I'm @stauffermatt on Twitter
Tags: laravel • lambo