PHP code example of laravel-ready / env-profile-manager
1. Go to this page and download the library: Download laravel-ready/env-profile-manager 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/ */
laravel-ready / env-profile-manager example snippets
return [
// Web route prefix
'route_prefix' => 'env-profile-manager',
// API route prefix
'api_prefix' => 'api/env-profile-manager',
// Middleware for web routes
'middleware' => ['web', 'auth'],
// Middleware for API routes
'api_middleware' => ['api', 'auth:sanctum'],
// Layout to extend for views
// Set to null to use the package's default layout
// Example: 'layouts.app' to use your application's layout
'layout' => 'env-profile-manager::layouts.default',
// Maximum number of .env backups to keep
'max_backups' => 10,
// Enable/disable features
'features' => [
'api' => true,
'web_ui' => true,
'backups' => true,
],
];
use LaravelReady\EnvProfiles\Models\EnvProfile;
use LaravelReady\EnvProfiles\Services\EnvFileService;
// Create a new profile
$profile = EnvProfile::create([
'name' => 'Production',
'app_name' => 'My Laravel App',
'content' => file_get_contents(base_path('.env.production')),
]);
// Activate a profile
$profile->activate();
// Use the EnvFileService
$envService = app(EnvFileService::class);
$currentEnv = $envService->read();
$envService->write($newContent);