Install via Composer:
composer require vendor/package-name
Publish the package config (if applicable) and run migrations:
php artisan vendor:publish --provider="Vendor\PackageName\PackageServiceProvider"
php artisan migrate
First use case: Leverage the package’s core functionality (e.g., PackageName::action()) or extend it with custom methods (new in 1.2.1). The documentation now includes examples for both default and custom method usage.
PackageName::process()) for common tasks.extend() facade or service provider:
// Register a custom method
PackageName::extend('customMethod', function ($param) {
return $param * 2; // Example logic
});
// Usage
$result = PackageName::customMethod(5); // Returns 10
AppServiceProvider:
public function boot()
{
PackageName::extend('customLogic', function () {
// Custom logic here
});
}
composer test
to inspect the test suite for patterns.process()). Prefix with custom_ or use namespaces.PackageName::extend('debugMethod', function ($input) {
\Log::debug('Custom method input:', ['input' => $input]);
return $input;
});
dd() Sparingly: The package may rely on lazy evaluation. Prefer logging or dump() for inspection.AppServiceProvider@register():
$this->app->extend('package.name', function ($service) {
return new CustomPackageService($service);
});
php artisan vendor:publish --tag="package-name-facades"
.env or config/package.php doesn’t conflict with defaults.$cached = Cache::remember('package_key', 60, function () {
return PackageName::expensiveMethod();
});
How can I help you explore Laravel packages today?