mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 15:03:44 +08:00
88366fe8af
* Write source map without creating temp file Less I/O, and one less place where we access the global path helpers. * Drop useless app_path() helper This was probably taken straight from Laravel. There is no equivalent concept in Flarum, so this should be safe to remove. * Deprecate global path helpers Developers using these helpers can inject the `Paths` class instead. * Stop storing paths as strings in container * Avoid using path helpers from Application class * Deprecate path helpers from Application class * Avoid using public_path() in prerequisite check a) The comparison was already outdated, as a different path was passed. b) We're trying to get rid of these global helpers.
72 lines
1.7 KiB
PHP
72 lines
1.7 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* For detailed copyright and license information, please view the
|
|
* LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
use Flarum\Foundation\Paths;
|
|
use Flarum\Install\AdminUser;
|
|
use Flarum\Install\BaseUrl;
|
|
use Flarum\Install\DatabaseConfig;
|
|
use Flarum\Install\Installation;
|
|
|
|
require __DIR__.'/../../vendor/autoload.php';
|
|
|
|
$host = getenv('DB_HOST') ?: 'localhost';
|
|
$port = intval(getenv('DB_PORT') ?: 3306);
|
|
$name = getenv('DB_DATABASE') ?: 'flarum_test';
|
|
$user = getenv('DB_USERNAME') ?: 'root';
|
|
$pass = getenv('DB_PASSWORD') ?: '';
|
|
$pref = getenv('DB_PREFIX') ?: '';
|
|
|
|
echo "Connecting to database $name at $host:$port.\n";
|
|
echo "Logging in as $user with password '$pass'.\n";
|
|
echo "Table prefix: '$pref'\n";
|
|
|
|
echo "\n\nCancel now if that's not what you want...\n";
|
|
echo "Use the following environment variables for configuration:\n";
|
|
echo "DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_PREFIX\n";
|
|
|
|
sleep(5);
|
|
|
|
echo "\nOff we go...\n";
|
|
|
|
/*
|
|
* Setup installation configuration
|
|
*/
|
|
|
|
$installation = new Installation(
|
|
new Paths([
|
|
'base' => __DIR__.'/tmp',
|
|
'public' => __DIR__.'/tmp/public',
|
|
'storage' => __DIR__.'/tmp/storage',
|
|
'vendor' => __DIR__.'/../../vendor',
|
|
])
|
|
);
|
|
|
|
$pipeline = $installation
|
|
->configPath('config.php')
|
|
->debugMode(true)
|
|
->baseUrl(BaseUrl::fromString('http://localhost'))
|
|
->databaseConfig(
|
|
new DatabaseConfig('mysql', $host, $port, $name, $user, $pass, $pref)
|
|
)
|
|
->adminUser(new AdminUser(
|
|
'admin',
|
|
'secret',
|
|
'admin@flarum.email'
|
|
))
|
|
->settings(['mail_driver' => 'log'])
|
|
->build();
|
|
|
|
/*
|
|
* Run the actual configuration
|
|
*/
|
|
|
|
$pipeline->run();
|
|
|
|
echo "Installation complete\n";
|