Installation
composer require apie/console
Requires PHP 8.1+ and Laravel 9+ (inferred from Apie's ecosystem).
First Use Case
The package provides CLI utilities for API development. Start by inspecting the apie/console namespace for available commands. Run:
php artisan list apie
(If no commands appear, check if the package registers them via service provider.)
Basic Integration
Publish the package's config (if available) and bind the Apie\Console\ConsoleServiceProvider in config/app.php:
'providers' => [
// ...
Apie\Console\ConsoleServiceProvider::class,
],
Command Registration
Extend Apie\Console\BaseCommand for custom commands:
namespace App\Console\Commands;
use Apie\Console\BaseCommand;
class GenerateApiCommand extends BaseCommand
{
protected $signature = 'apie:generate {name}';
protected $description = 'Generate API boilerplate';
public function handle()
{
$this->info('Generating API for: ' . $this->argument('name'));
// Logic here
}
}
Register in app/Console/Kernel.php:
protected $commands = [
\App\Console\Commands\GenerateApiCommand::class,
];
API Interaction via CLI Use the package to interact with Apie's core (e.g., schema generation, validation):
php artisan apie:schema:generate --path=app/Http/Schemas
(Verify available commands via php artisan or the package's source.)
Event Listeners
Attach listeners to Apie events (e.g., apie.schema.generated) for post-processing:
namespace App\Listeners;
use Apie\Console\Events\SchemaGenerated;
class LogSchemaEvent
{
public function handle(SchemaGenerated $event)
{
\Log::info('Schema generated:', ['path' => $event->path]);
}
}
Register in EventServiceProvider.
Configuration Overrides
Override Apie's console config (if published) in config/apie.php:
'console' => [
'default_command' => 'apie:schema:validate',
'log_level' => 'debug',
],
No Public Documentation
console directory.Apie\Console\BaseCommand for shared functionality.config/apie.php:
'debug' => env('APP_DEBUG', true),
Monorepo Quirks
composer.json.Laravel Integration
ArtisanServiceProvider.register():
$this->commands([
\Apie\Console\Commands\ValidateSchema::class,
]);
Event System
apie.schema.validated may not be documented. Discover them via:
\Apie\Console\Events\*; // Check the namespace for available events.
--verbose with commands to debug:
php artisan apie:schema:generate --verbose
storage/logs/laravel.log by default. Increase log level:
'console' => [
'log_level' => 'debug',
],
php artisan tinker
>>> \Apie\Console\Helpers::validateSchema('path/to/schema');
Custom Commands
Extend BaseCommand to reuse Apie’s CLI helpers (e.g., output formatting, argument parsing):
use Apie\Console\Helpers;
class CustomCommand extends BaseCommand {
public function handle() {
Helpers::line('Custom output', 'comment');
}
}
Middleware for Commands Add middleware to commands via traits or decorators:
use Apie\Console\Traits\AuthenticatesCommands;
class SecureCommand extends BaseCommand {
use AuthenticatesCommands;
// ...
}
Hook into Apie’s Pipeline
Override Apie’s console pipeline in app/Providers/AppServiceProvider:
public function boot() {
\Apie\Console\ConsoleServiceProvider::macro('extendPipeline', function ($pipeline) {
$pipeline->prepend(\App\Console\Middleware\LogCommand::class);
});
}
How can I help you explore Laravel packages today?