Main menu
WalkswithMeLaravelWorkbench Package Development for Laravel 5

Workbench Package Development for Laravel 5

workbench package development for laravel 5.x is depreciated , so before starting with this approach make sure you’re aware of it. Its just a matter for Laravel 5.0 version only later version support packager CLI command for creating packages. So if you’re planning to develop applications using Laravel 5.0 and needs to create packages rapidly then only try this option, Other  wise you can check my previous post regarding package creation of laravel 5.x.

Also if you’re planning to develop on Laravel 5.1 or later simply use this packages for creating your own packages.

Still you want workbench package development for laravel 5 just follow the instructions here, I select this method only due to few reason first of all php requirement for Laravel 5.0 is 5.4 or greater, most of the shared host available now are in PHP 5.4.x (August 2015).

Ok  lets start workbench pattern,

First you have to add the workbench support in your  composer.json of root folder like below.


"illuminate/workbench": "dev-master"

Now you can add the service provider in config\app.php file like below.


'Illuminate\Workbench\WorkbenchServiceProvider'

Next step is to create a workbench configuration files in your config folder like  config\workbench.php and add the following content.


<?php
return [
/*
|--------------------------------------------------------------------------
| Workbench Author Name
|--------------------------------------------------------------------------
|
| When you create new packages via the Artisan "workbench" command your
| name is needed to generate the composer.json file for your package.
| You may specify it now so it is used for all of your workbenches.
|
*/
'name' => 'jobin jose',
/*
|--------------------------------------------------------------------------
| Workbench Author E-Mail Address
|--------------------------------------------------------------------------
|
| Like the option above, your e-mail address is used when generating new
| workbench packages. The e-mail is placed in your composer.json file
| automatically after the package is created by the workbench tool.
|
*/
'email' => 'jobinjose@xx.com',
];

Then just make sure you run the composer dumpautoload (some times its required composer dumpautoload – o).

Now you can simply creates packages using old laravel workbech CLI like.


php artisan workbench VendorName/PackageName

Ok now just check how it compatible for Laravel 5.x pattern, we know in Laravel 4.2 doesn’t have resource folder for overriding our packages view that has been done with app\view\ folder so here its different even if you created the Packages using workbench you can make it Laravel 5.x way with following two lines in your serviceprovider of packages. add the following lines in your service provider boot method.


$this->publishes([
__DIR__.'/views' => base_path('resources/views/vendor/packagename'),
]);

Then add your namespace in Laravel root’s composer.json like below.


"psr-4": {
"App\\": "app/",
"Walkswithme\\Users\\": "workbench/walkswithme/users/src"
}
},

Make sure you run the composer dumpautoload for loading your namespaces.

 composer dumpautoload

So you can run the vendor publish command for creating override for your packages.


php artisan vendor:publish

This approach is experimental for quick development , not a good practise , to compromise Laravel 5.0 with PHP 5.4.x other wise always choose Laravel 5.1 if you have PHP 5.5.9 support on your hosting provider

 

Now you able to create a package using workbench pattern in Laravel 5.

Hope this article will help you to develop packages quickly. 🙂 🙂 🙂

 

One thought on “Workbench Package Development for Laravel 5

  1. Pingback: Laravel 5 package development | WalksWithMe

Leave a Reply

Your email address will not be published. Required fields are marked *

 

FacebookTwitterGoogle+RSS