Packages

Creation

Package creation is easy task in Lavalite, our package builder helps you to build all basic files required for the package. The beautiful package building tool helps you to complete almost 60% of your coding task in just few hours. The more time you spend on the package builder will reduce the coding time for the entire project.

Structure

Here is the basic folder structure for a lavalite package. Based on other functionalities you select it will generate additional codes and folders in the package.

 Root - Package root folder.
 	+ config - Folder for configuration files.
    + database - Folder for migrations & seeds.
        + migrations
        + seeds
    + public - Folder for files to be publish to the public folder.
    + resources
        + lang - Folder for language files.
            + en
        + views - Views for different type of users.
            + admin
            + public
            + default
    + routes - Route files
    + src  - Contains all core programs.
        + Facades
        + Http
        	+ Controllers
        	+ Request
        	+ Response 
        + Interfaces
        + Models
        + Policies
        + Providers
        + Repositories
            + Criteria
            + Eloquent
            + Presenter
    + tests - Test files

Installation

Once downloaded the packages form the package builder extract the package to the packages folder in the project and add the following line of code in the composer.json file.

"psr-4": {
    ...
    "Provider\\Package\\": "packages/provider/Package/src",
    ...
},
"files": [
    ...
    // add this line of code if you have added any helper function for the package
    "packages/provider/Package/src/helpers.php"
    ...
]

Run composer auto-load command in the command line to add the package class to composer class map. Once it is done add service provider and facades to the config/app.php to link the package to the project.

'providers'       => [
      ...
      Provider\Package\Providers\PackageServiceProvider::class,
      ...
],

'aliases'         => [
      ...
      'Package'         => Provider\Package\Facades\Package::class,
      ...
],

Publishing files

If you want to customize the configurations, languages, views and public files publish the files to respective folders using artisan command.

php artisan vendor:publish --provider="Provider\Package\Providers\PackageServiceProvider" --tag="config"
php artisan vendor:publish --provider="Provider\Package\Providers\PackageServiceProvider" --tag="lang"
php artisan vendor:publish --provider="Provider\Package\Providers\PackageServiceProvider" --tag="view"
php artisan vendor:publish --provider="Provider\Package\Providers\PackageServiceProvider" --tag="public"

Migration and Seeds

Once package is registers with service provider you can use php artisan migrate command to migrate the database with the tables. And use php artisan db:seed --class=PackageTableSeeder to seed the tables with the default data if required.

Replace Provider with actual provider name and Package with actual package name in all code samples. For more information about the package development view the Package Development documentation in laravel.com.

Customization

Once the package is downloaded you have to customize the package according to the requirement. You can make you of our slack channel for clearing your doubts on package customization.