A less known, but very important feature of Mojolicious is the ability to add your own commands to your web application. These commands can ship with your app, so that your management utilities have direct knowledge of your application.
These are some examples of commands that ship with the framework:
There are also commands not tied to a specific app:
Here is the thing to remember:
It's super easy to write your own command
How many times have you wasted time manually adding your preferred toolkits to your web app? How about saving yourself some time by throwing this command together?
$ mojo generate app boilerplate -w bootstrap -w backbone -w font-awesome
Or maybe you have little scripts that manage your database, scripts with hard-coded database connection info? Or maybe you programatically pull config info from a separate file? Why not make your life easier and get the database connection directly from the app?
With Mojolicious commands, you get direct access to your entire web app for free; you can even run a web request against it to get the results of a route, and use that information in your command.
There's no difference between the built-in commands and the commands you write yourself.
And it gets even better. What is the deployment process for your app? Multiple steps? Why not simplify it to one step, and distribute it with your web app?
$ myapp deploy
So much more is possible. For example, the recently released deploy heroku eliminates the need to know anything about the deploy platform, instead handling all the details with sensible defaults.
Mojolicious commands are extremely powerful, and CPAN is waiting - what commands have you hoped for in the past? What can you throw together to make your development that much easier?
Your customized command is only one subroutine away!comments powered by Disqus