1. Go to this page and download the library: Download aminulbd/laravel-packages library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aminulbd / laravel-packages example snippets
return [
'roots' => [
'default' => [
'forced' => false, // force enable all packages inside this location.
'location' => '/packages',
],
// More paths...
],
// Other configurations...
];
return [
'id' => 'yourdomain.yourpackage', // Unique ID of the package
'autoload' => [
'YourDomain\\YourPackage\\' => 'src/',
],
// Service provider class of the package, must extend Laravel's ServiceProvider
'provider' => YourDomain\YourPackage\YourPackageServiceProvider::class,
];
namespace YourDomain\YourPackage;
use Illuminate\Support\ServiceProvider;
class YourPackageServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// Register bindings in the container.
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// Register routes, views, translations, and other package resources.
}
}
// File: /packages/YourPackage/routes/web.php
use Illuminate\Support\Facades\Route;
Route::get('/your-package', function () {
return 'Hello from YourPackage!';
});
public function boot()
{
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
// Load other resources like views, migrations, etc.
}
return [
// ...
'enabled' => [
'yourdomain.yourpackage',
// Add other package IDs to enable
],
];
namespace App\Services;
use AminulBD\Package\Laravel\PackageActivationHandler;
class Activator implements PackageActivationHandler
{
/**
* Get the list of enabled package IDs.
*
* @return array
*/
public function enabled(): array
{
// Fetch the enabled package IDs from the database or other storage
return \App\Models\ActivatedPackage::pluck('id')->toArray();
}
}