PHP code example of jmrashed / php-installer
1. Go to this page and download the library: Download jmrashed/php-installer 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/ */
jmrashed / php-installer example snippets
return [
'app_name' => 'Your Application',
'version' => '1.0.0',
'php_version' => '7.4',
',
'migration_support' => true,
'migration_path' => __DIR__ . '/../database/migrations',
'seeder_path' => __DIR__ . '/../database/seeders',
'supported_databases' => [
'mysql' => ['name' => 'MySQL', 'extension' => 'pdo_mysql', 'default_port' => '3306'],
'pgsql' => ['name' => 'PostgreSQL', 'extension' => 'pdo_pgsql', 'default_port' => '5432'],
'sqlite' => ['name' => 'SQLite', 'extension' => 'pdo_sqlite', 'default_port' => null]
]
];
// 2024_01_01_000001_create_users_table.php
return function ($pdo) {
$pdo->exec("
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
");
echo "✅ Table 'users' created.\n";
};
// AdminSeeder.php
return function ($pdo) {
$stmt = $pdo->prepare("INSERT INTO users (username, email, password) VALUES (?, ?, ?)");
$stmt->execute(['admin', '[email protected] ', password_hash('admin123', PASSWORD_DEFAULT)]);
echo "✅ Admin user seeded.\n";
};
// config/installer.php
return [
'app_name' => 'Laravel Application',
' => true,
'migration_path' => __DIR__ . '/../database/migrations',
'seeder_path' => __DIR__ . '/../database/seeders'
];
// config/installer.php
return [
'app_name' => 'Custom PHP App',
'rt' => true,
'migration_path' => __DIR__ . '/../database/migrations',
'seeder_path' => __DIR__ . '/../database/seeders'
];
private $steps = [
'welcome',
'license',
'system_check',
'db_config',
'db_import',
'app_config',
'admin_account',
'custom_step', // Add your custom step
'finish'
];
php-installer/
├── config/
│ └── installer.php # Configuration settings
├── database/
│ └── db.sql # Database schema
├── public/
│ └── index.php # Entry point
├── src/
│ ├── Core/ # Core installer classes
│ ├── Controllers/ # Request handlers
│ ├── Views/ # UI templates
│ ├── Assets/ # CSS, JS, images
│ └── Templates/ # Config templates
└── storage/
├── logs/ # Installation logs
└── installer.lock # Installation lock file