Running Laravel Artisan Commands from your Admin Dashboard / GUI

Posted 22nd January 2014

Some­times you may wish to run Arti­san com­mands from your admin dash­board /​appli­ca­tion, with­out using the com­mand line. Per­haps you don’t have access to the com­mand line (in which case per­haps it’s time to switch host­ing!), or more likely per­haps you want to man­u­ally run tasks right from your appli­ca­tion. Here’s a quick guide to how you might set that up.

Run­ning a command

To run a com­mand pro­gram­mat­i­cally, you sim­ply do this:

Artisan::call('my-command', array());

The first argu­ment is the name of the com­mand, the sec­ond your options, which I’m going to ignore for brevity.

It’s prob­a­bly more use­ful if you can get a hold of the command’s out­put; you can do this by pass­ing a third argu­ment, which should be a class that imple­ments Symfony\Component\Console\Output\OutputInterface. Per­haps the most use­ful of these classes is StreamOutput. So, for exam­ple, you can write the out­put to a file:

A Concrete5 Development Tutorial; Creating a Quote Block

Posted 7th July 2011

I needed the means to add a quote to a web­site I was work­ing on — a sim­ple task, which could be acheieved by sim­ply adding a text or HTML block. How­ever this can be taken a step fur­ther by imple­ment­ing a sim­ple block type specif­i­cally for quotes, with the markup gen­er­ated for you.

To mark up a quote seman­ti­cally, we’ll want a blockquote for the con­tent and a cite for the source (or author), so the HTML needs to look some­thing like this:

<blockquote>
<p>It is the mark of an educated mind to be able to entertain a thought without accepting it.</p>
<p><cite>Aristotle</cite></p>
</blockquote>

…which will give us some­thing a lit­tle like this:

Creating a Concrete5 Package: Integrating the Craftyslide JQuery Plugin

Posted 5th July 2011

In this sim­ple tuto­r­ial, I’m going to show how Concrete5 can be extended to inte­grate a third-​party JQuery plu­gin to enhance an exist­ing mod­ule, and then how this can be encap­su­lated in a pack­age. I’m going to allow the slideshow mod­ule to dis­play images using the clean & light­weight Craftys­lide plu­gin, pic­tured below.

The Craftyslide JQuery Slider plugin in action
The Craftys­lide plu­gin in action

Concrete5 comes shipped with sim­ple slideshow func­tion­al­ity in the form of a block called, imag­i­na­tively enough, slideshow. As this is part of the core you can find it in /concrete/blocks/slideshow. It’s in the con­crete direc­tory to keep it sep­a­rate from cus­tom code. And some cus­tom code is what we’re going to pro­duce — to over­ride the out­put of that block, and then to encap­su­late this into a package.

Taxonomy Colour: Drupal Module Development Tutorial (Part Two)

Posted 4th July 2011

In the first part, I looked at cre­at­ing the data­base schema for a sim­ple Dru­pal mod­ule designed to allow you to asso­ciate colours with tax­on­omy terms. In this sec­ond part, I’ll look at the admin­is­tra­tion aspects of the mod­ule. In essence, what we need to do is as follows:

  • Since colour-​coding may only be appro­pri­ate to cer­tain vocab­u­lar­ies (e.g. cat­e­gories) and not oth­ers (tags, per­haps). We need to pro­vide the user with the option to spec­ify which vocab­u­lar­ies are applicable.
  • The user needs to be able to spec­ify a colour when adding or edit­ing a term, where appropriate.
  • We need to pro­vide a mech­a­nism which allows the colour asso­ci­ated with a term to be stored, retrieved, and to be displayed.