mirror of
https://github.com/archtechx/airwire.git
synced 2025-12-12 02:34:04 +00:00
register component in AppServiceProvider automatically
This commit is contained in:
parent
20f8881897
commit
de1c1faaa7
2 changed files with 14 additions and 4 deletions
12
src/Commands/Component.php
Normal file
12
src/Commands/Component.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
namespace Airwire\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Component {
|
||||
public static function register(string $name)
|
||||
{
|
||||
$service_provider = base_path() . "\app\Providers\AppServiceProvider.php";
|
||||
file_put_contents($service_provider, preg_replace('/register[(][)][\s\S].*/', "register() {\n\t\tAirwire::component('" . Str::snake($name) . "', {$name}::class);", file_get_contents($service_provider)));
|
||||
}
|
||||
}
|
||||
|
|
@ -33,9 +33,7 @@ class ComponentCommand extends Command
|
|||
}
|
||||
PHP);
|
||||
|
||||
$this->line("✨ Component app/Airwire/{$name}.php has been created!\n");
|
||||
|
||||
$this->warn("🚧 Don't forget to register the component! Add the following line to AppServiceProvider:");
|
||||
$this->line("\n\n Airwire::component('" . Str::snake($name) . "', {$name}::class);\n\n");
|
||||
Component::register($name);
|
||||
$this->line("✨ Component app/Airwire/{$name}.php has been created and registered!\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue