Bagisto Packaging Best Practices
Bagisto Packaging Best Practices
Bagisto Packaging Best Practices
TECHNICAL
DOCUMENTATION
Oluwatobi Odekunle,
Lead Developer.
PACKAGING BEST PRACTICES
Summary:
This documentation explains step by step what packaging is all about with respect to
laravel, vueJS, bagisto and general development.
Laravel Packaging
Packages are the primary way of adding functionality to Laravel. Packages might be
anything from a great way to work with dates like Carbon or a package that allows you
to associate files with Eloquent models like Spatie's Laravel Media Library.
There are different types of packages. Some packages are stand-alone, meaning they
work with any PHP framework. Carbon and PHPUnit are examples of stand-alone
packages. Any of these packages may be used with Laravel by requiring them in your
composer.json file.
On the other hand, other packages are specifically intended for use with Laravel. These
packages may have routes, controllers, views, and configuration specifically intended to
enhance a Laravel application. To learn more about how to develop your own package,
kindly follow this official laravel guide https://laravel.com/docs/7.x/packages
A package is a unit added to your application for enhancement which includes routes,
controllers, views, and configuration specifically. Packages are created to manage your
large applications into smaller units.
In Bagisto, several packages are available at path packages/Webkul/. You can find a
basic tree-structure of the package below:
- ACME/HelloWorld/
- publishable/assets
- css/
- images/
- js/
- src/
- Config/
- acl.php
- admin-menu.php
- Console/
- Commands/
- Contracts/
- Database/
- Migrations/
- Seeders/
- Events/
- Http/
- Controllers/
- Admin/
- HelloWorldController.php
- Shop/
- HelloWorldController.php
- Middleware/
- Requests/
- admin-routes.php
- shop-routes.php
- Listeners/
- Mail/
- Models/
- Providers/
- HelloWorldServiceProvider.php
- ModuleServiceProvider.php
- Repositories/
- Resources/
- assets/
- images/
- js/
- app.js
- sass/
- admin.scss
- default.scss
- velocity.scss
- lang/
- views/
- admin/
- layouts/
- style.blade.php
- index.blade.php
- shop/
- default/
- index.blade.php
- velocity/
- index.blade.php
- package.json
- webpack.mix.js
You want to learn how to create your own package? Follow this link if yes. Bagisto Package
Development
Available Packages from WebKul
Bagisto comes with several interesting packages which can be found inside the
packages folder. The WebKul folder in the packages folder contains the following
packages:
❖ Admin
❖ API
❖ Attribute
❖ BookingProduct
❖ CartRule
❖ CatalogRule
❖ Category
❖ Checkout
❖ CMS
❖ Core
❖ Customer
❖ Inventory
❖ Payment
❖ PayPal
❖ Product
❖ Rule
❖ Sales
❖ Shipping
❖ Shop
❖ SocialLogin
❖ Tax
❖ Theme
❖ Ui
❖ User
❖ Velocity
NOTE: All of those packages communicate with one another, do not break them when
creating a new package.
WHY DO WE NEED PACKAGING
Basically, a laravel package is a mini laravel application that is built to enhance a laravel
application. Those packages can be re-used on any laravel application that supports it.
These packages may have routes, controllers, views, and configuration specifically
intended to enhance a Laravel application.
Since Bagisto is a complete eCommerce solution, why then do we need to create
package and what are the impact?
The following will talk about the effect of implementing a package for every new feature
you want to create.
However, as a professional, you might not need to create a new package if you are not
inroducing a new feature. If you are only extending the created ones by WebKul, you
can modify them but be careful. If you now need to upgrade, make sure you have a
backup. A package is just a folder that contains a laravel mini app. You can then re-use
them on the new upgrade.
Also, you can assign each package to other developers if you are working with many,
each developer will take ownership of the assigned package.
Finally, if you are creating a new feature that is not part of Bagisto, kindly create your
own package and save it (either locally or on the cloud, you can even publish it) to avoid
losing all your solutions.
PACKAGES CREATED
Since Bagisto comes with Velocity theme and we might need to use another theme in
future. To follow the best practices, I created a theme called Smooth which is exactly
like Velocity for now. This theme would be the one we will be working on as soon as we
have a new multi vendor extension.
How to create a bagisto theme
Also, Bagisto comes with only PayPal and since Paystack is what we need to
implement. I have created and configured a new package called Paystack which is
registed under the WebKul folder as well. The package is configured to work with every
other packages like Payment, Shop, Checkout etc.