{"id":722,"date":"2013-01-21T22:53:04","date_gmt":"2013-01-21T22:53:04","guid":{"rendered":"http:\/\/blogs.kent.ac.uk\/webdev\/?p=722"},"modified":"2013-01-21T22:53:04","modified_gmt":"2013-01-21T22:53:04","slug":"laravel-3-calling-bundles-from-the-cli","status":"publish","type":"post","link":"https:\/\/blogs.kent.ac.uk\/webdev\/2013\/01\/21\/laravel-3-calling-bundles-from-the-cli\/","title":{"rendered":"Laravel 3: calling bundles from the CLI"},"content":{"rendered":"<p>We&#8217;ve been using <a href=\"http:\/\/laravel.com\">Laravel<\/a>\u00a0for almost a year now in the Kent Uni webdev team on projects such as our <a href=\"https:\/\/github.com\/unikent\/programmes-plant\">course data tool<\/a>. We&#8217;ve found it a great alternative both to older medium-weight PHP frameworks like CodeIgniter and to some of the newer ones like FuelPHP. Even when we&#8217;ve had a few issues with it we were able to get our changes merged into the core, thanks to the <a href=\"https:\/\/github.com\/laravel\/laravel\">vibrant community<\/a>.<\/p>\n<p>One thing we started to use recently was the handy Laravel caching bundle <a href=\"https:\/\/github.com\/Apathetic012\/filch\">Filch<\/a>, which extends the built-in Laravel Cache class.\u00a0It worked just fine until we needed to run a Laravel <a href=\"http:\/\/laravel.com\/docs\/artisan\/tasks\">task<\/a> from the command line. It just refused to acknowledge that the bundle even existed, even though it normally works just fine.<\/p>\n<p>The solution, it seems, lies in the fact that in CLI Laravel calls a bundle&#8217;s start.php after it&#8217;s already set its drivers. It just won&#8217;t see any of your bundles.<\/p>\n<p>Too late.<\/p>\n<p>So instead just copy the contents of each bundle&#8217;s start.php into the application-level start.php<\/p>\n<p>So in our case we had to put something like:<\/p>\n<pre>Autoloader::map(array(\r\n 'Filch\\\\Cache' =&gt; Bundle::path('filch').'cache.php',\r\n));<\/pre>\n<pre>Cache::extend('filch', function(){\r\n return new Filch\\Cache(path('storage').'cache'.DS);\r\n});<\/pre>\n<p>into our main start.php<\/p>\n<p>All done!<\/p>\n<p>Of course, if you know a better way of doing this, drop us a line. And bear in mind Laravel 4 is coming out soon. I&#8217;m not too sure if all this changes in that. Probably.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve been using Laravel\u00a0for almost a year now in the Kent Uni webdev team on projects such as our course data tool. We&#8217;ve found it &hellip; <a href=\"https:\/\/blogs.kent.ac.uk\/webdev\/2013\/01\/21\/laravel-3-calling-bundles-from-the-cli\/\">Read&nbsp;more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1464],"tags":[23143,23142,23144,9008,707],"_links":{"self":[{"href":"https:\/\/blogs.kent.ac.uk\/webdev\/wp-json\/wp\/v2\/posts\/722"}],"collection":[{"href":"https:\/\/blogs.kent.ac.uk\/webdev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.kent.ac.uk\/webdev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.kent.ac.uk\/webdev\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.kent.ac.uk\/webdev\/wp-json\/wp\/v2\/comments?post=722"}],"version-history":[{"count":1,"href":"https:\/\/blogs.kent.ac.uk\/webdev\/wp-json\/wp\/v2\/posts\/722\/revisions"}],"predecessor-version":[{"id":723,"href":"https:\/\/blogs.kent.ac.uk\/webdev\/wp-json\/wp\/v2\/posts\/722\/revisions\/723"}],"wp:attachment":[{"href":"https:\/\/blogs.kent.ac.uk\/webdev\/wp-json\/wp\/v2\/media?parent=722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.kent.ac.uk\/webdev\/wp-json\/wp\/v2\/categories?post=722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.kent.ac.uk\/webdev\/wp-json\/wp\/v2\/tags?post=722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}