PHP code example of melchiorkokernoot / laravel-autowire-config
1. Go to this page and download the library: Download melchiorkokernoot/laravel-autowire-config 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');
melchiorkokernoot / laravel-autowire-config example snippets
class Foo {
public function __construct(
#[Config('app.name')]
public string $myConfiguredAppName,
){}
}
return [
'strategy' => PropNameStrategy::class,
];
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__),
);
use MelchiorKokernoot\LaravelAutowireConfig\Application;
$app = new Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__),
);
class Foo {
public function __construct(
#[Config('app.name','default value')]
public string $myConfiguredAppName,
){}
}
class Foo implements AutowiresConfigs{
public function __construct(
#[StringConfig('app.name')]
public StringConfig $appName,
){}
}
$foo = new Foo(config('app.name'));
class Foo implements AutowiresConfigs{
public function __construct(
public StringConfig $appName,
){}
}
$foo = new Foo(config('app.name'));
class Foo implements AutowiresConfigs{
public function __construct(
public StringConfig $appName,
){}
public function bar(){
(string) $this->appName
$this->appName->value->v();
$this->appName->value->v;
return $this->appName->value();
}
}
bash
php artisan vendor:publish --provider="MelchiorKokernoot\LaravelAutowireConfig\LaravelAutowireConfigServiceProvider"