mirror of https://github.com/flarum/flarum
Clean up, add header comments
parent
5aa4530447
commit
dd6cb2f6ce
|
@ -8,7 +8,6 @@ github_branch = "1.3.0"
|
||||||
github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"
|
github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"
|
||||||
|
|
||||||
# Server Configuration
|
# Server Configuration
|
||||||
|
|
||||||
hostname = "flarum.dev"
|
hostname = "flarum.dev"
|
||||||
|
|
||||||
# Set a local private network IP address.
|
# Set a local private network IP address.
|
||||||
|
|
23
admin.php
23
admin.php
|
@ -1,28 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
use Flarum\Core;
|
use Flarum\Core;
|
||||||
|
use Flarum\Forum\Middleware\HandleErrors;
|
||||||
|
use Franzl\Middleware\Whoops\Middleware as WhoopsMiddleware;
|
||||||
use Zend\Diactoros\Server;
|
use Zend\Diactoros\Server;
|
||||||
use Zend\Stratigility\MiddlewarePipe;
|
use Zend\Stratigility\MiddlewarePipe;
|
||||||
|
|
||||||
// Instantiate the application, register providers etc.
|
|
||||||
$app = require __DIR__.'/flarum/bootstrap.php';
|
$app = require __DIR__.'/flarum/bootstrap.php';
|
||||||
|
|
||||||
// Set up everything we need for the frontend
|
|
||||||
$app->register('Flarum\Admin\AdminServiceProvider');
|
$app->register('Flarum\Admin\AdminServiceProvider');
|
||||||
|
|
||||||
// Build a middleware pipeline for Flarum
|
|
||||||
$admin = new MiddlewarePipe();
|
$admin = new MiddlewarePipe();
|
||||||
$admin->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
|
$admin->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
|
||||||
$admin->pipe($app->make('Flarum\Admin\Middleware\LoginWithCookieAndCheckAdmin'));
|
$admin->pipe($app->make('Flarum\Admin\Middleware\LoginWithCookieAndCheckAdmin'));
|
||||||
|
|
||||||
$adminPath = parse_url(Core::config('admin_url'), PHP_URL_PATH);
|
$adminPath = parse_url(Core::config('admin_url'), PHP_URL_PATH);
|
||||||
$admin->pipe($adminPath, $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.admin.routes')]));
|
$router = $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.admin.routes')]);
|
||||||
|
|
||||||
|
$admin->pipe($adminPath, $router);
|
||||||
|
|
||||||
// Handle errors
|
|
||||||
if (Core::inDebugMode()) {
|
if (Core::inDebugMode()) {
|
||||||
$admin->pipe(new \Franzl\Middleware\Whoops\Middleware());
|
$admin->pipe(new WhoopsMiddleware());
|
||||||
} else {
|
} else {
|
||||||
$admin->pipe(new \Flarum\Forum\Middleware\HandleErrors(base_path('error')));
|
$admin->pipe(new HandleErrors(base_path('error')));
|
||||||
}
|
}
|
||||||
|
|
||||||
$server = Server::createServer(
|
$server = Server::createServer(
|
||||||
|
|
23
api.php
23
api.php
|
@ -1,28 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Flarum\Api\Middleware\JsonApiErrors;
|
||||||
use Flarum\Core;
|
use Flarum\Core;
|
||||||
|
use Franzl\Middleware\Whoops\Middleware as WhoopsMiddleware;
|
||||||
use Zend\Diactoros\Server;
|
use Zend\Diactoros\Server;
|
||||||
use Zend\Stratigility\MiddlewarePipe;
|
use Zend\Stratigility\MiddlewarePipe;
|
||||||
|
|
||||||
// Instantiate the application, register providers etc.
|
|
||||||
$app = require __DIR__.'/flarum/bootstrap.php';
|
$app = require __DIR__.'/flarum/bootstrap.php';
|
||||||
|
|
||||||
// Set up everything we need for the API
|
|
||||||
$app->register('Flarum\Api\ApiServiceProvider');
|
$app->register('Flarum\Api\ApiServiceProvider');
|
||||||
|
|
||||||
// Build a middleware pipeline for the API
|
|
||||||
$api = new MiddlewarePipe();
|
$api = new MiddlewarePipe();
|
||||||
$api->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
|
$api->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
|
||||||
$api->pipe($app->make('Flarum\Api\Middleware\LoginWithHeader'));
|
$api->pipe($app->make('Flarum\Api\Middleware\LoginWithHeader'));
|
||||||
|
|
||||||
$apiPath = parse_url(Core::config('api_url'), PHP_URL_PATH);
|
$apiPath = parse_url(Core::config('api_url'), PHP_URL_PATH);
|
||||||
$api->pipe($apiPath, $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.api.routes')]));
|
$router = $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.api.routes')]);
|
||||||
|
|
||||||
|
$api->pipe($apiPath, $router);
|
||||||
|
|
||||||
// Handle errors
|
|
||||||
if (Core::inDebugMode()) {
|
if (Core::inDebugMode()) {
|
||||||
$api->pipe(new \Franzl\Middleware\Whoops\Middleware());
|
$api->pipe(new WhoopsMiddleware());
|
||||||
} else {
|
} else {
|
||||||
$api->pipe(new \Flarum\Api\Middleware\JsonApiErrors());
|
$api->pipe(new JsonApiErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
$server = Server::createServer(
|
$server = Server::createServer(
|
||||||
|
|
|
@ -1,27 +1,43 @@
|
||||||
<?php
|
<?php
|
||||||
define('LARAVEL_START', microtime(true));
|
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Flarum\Core;
|
||||||
|
use Flarum\Core\Application;
|
||||||
|
use Illuminate\Cache\FileStore;
|
||||||
|
use Illuminate\Cache\Repository;
|
||||||
|
use Illuminate\Config\Repository as ConfigRepository;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
|
||||||
|
define('FLARUM_START', microtime(true));
|
||||||
|
|
||||||
require __DIR__ . '/vendor/autoload.php';
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
// Temp while franzliedke/studio doesn't autoload files
|
// franzliedke/studio currently doesn't autoload files (see issue below), so we
|
||||||
|
// will need to load them manually if we're using studio.
|
||||||
|
// https://github.com/franzliedke/studio/issues/29
|
||||||
if (file_exists(__DIR__ . '/core')) {
|
if (file_exists(__DIR__ . '/core')) {
|
||||||
require __DIR__ . '/core/src/helpers.php';
|
require __DIR__ . '/core/src/helpers.php';
|
||||||
require __DIR__ . '/core/vendor/swiftmailer/swiftmailer/lib/swift_required.php';
|
require __DIR__ . '/core/vendor/swiftmailer/swiftmailer/lib/swift_required.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
$app = new Flarum\Core\Application(
|
$app = new Application(realpath(__DIR__));
|
||||||
realpath(__DIR__)
|
|
||||||
);
|
|
||||||
$app->instance('path.public', __DIR__.'/..');
|
$app->instance('path.public', __DIR__.'/..');
|
||||||
|
|
||||||
Illuminate\Container\Container::setInstance($app);
|
Illuminate\Container\Container::setInstance($app);
|
||||||
|
|
||||||
// LoadConfiguration
|
|
||||||
if (file_exists($configFile = __DIR__.'/../config.php')) {
|
if (file_exists($configFile = __DIR__.'/../config.php')) {
|
||||||
$app->instance('flarum.config', include $configFile);
|
$app->instance('flarum.config', include $configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
$app->instance('config', $config = new \Illuminate\Config\Repository([
|
$app->instance('config', $config = new ConfigRepository([
|
||||||
'view' => [
|
'view' => [
|
||||||
'paths' => [
|
'paths' => [
|
||||||
realpath(base_path('resources/views'))
|
realpath(base_path('resources/views'))
|
||||||
|
@ -53,7 +69,6 @@ $app->instance('config', $config = new \Illuminate\Config\Repository([
|
||||||
],
|
],
|
||||||
]));
|
]));
|
||||||
|
|
||||||
// ConfigureLogging
|
|
||||||
$logger = new Monolog\Logger($app->environment());
|
$logger = new Monolog\Logger($app->environment());
|
||||||
$logPath = $app->storagePath() . '/logs/flarum.log';
|
$logPath = $app->storagePath() . '/logs/flarum.log';
|
||||||
$handler = new \Monolog\Handler\StreamHandler($logPath, Monolog\Logger::DEBUG);
|
$handler = new \Monolog\Handler\StreamHandler($logPath, Monolog\Logger::DEBUG);
|
||||||
|
@ -63,12 +78,6 @@ $logger->pushHandler($handler);
|
||||||
$app->instance('log', $logger);
|
$app->instance('log', $logger);
|
||||||
$app->alias('log', 'Psr\Log\LoggerInterface');
|
$app->alias('log', 'Psr\Log\LoggerInterface');
|
||||||
|
|
||||||
// Register some services
|
|
||||||
use Flarum\Core;
|
|
||||||
use Illuminate\Cache\FileStore;
|
|
||||||
use Illuminate\Cache\Repository;
|
|
||||||
use Illuminate\Filesystem\Filesystem;
|
|
||||||
|
|
||||||
$app->singleton('cache', function ($app) {
|
$app->singleton('cache', function ($app) {
|
||||||
$store = new FileStore(new Filesystem(), storage_path('framework/cache'));
|
$store = new FileStore(new Filesystem(), storage_path('framework/cache'));
|
||||||
$repository = new Repository($store);
|
$repository = new Repository($store);
|
||||||
|
@ -77,7 +86,6 @@ $app->singleton('cache', function($app) {
|
||||||
});
|
});
|
||||||
$app->alias('cache', 'Illuminate\Contracts\Cache\Repository');
|
$app->alias('cache', 'Illuminate\Contracts\Cache\Repository');
|
||||||
|
|
||||||
// RegisterProviders
|
|
||||||
$serviceProviders = [
|
$serviceProviders = [
|
||||||
'Flarum\Core\DatabaseServiceProvider',
|
'Flarum\Core\DatabaseServiceProvider',
|
||||||
'Flarum\Core\Settings\SettingsServiceProvider',
|
'Flarum\Core\Settings\SettingsServiceProvider',
|
||||||
|
@ -114,7 +122,6 @@ if (Core::isInstalled()) {
|
||||||
$app->register(new \Flarum\Support\ExtensionsServiceProvider($app));
|
$app->register(new \Flarum\Support\ExtensionsServiceProvider($app));
|
||||||
}
|
}
|
||||||
|
|
||||||
// BootProviders
|
|
||||||
$app->boot();
|
$app->boot();
|
||||||
|
|
||||||
return $app;
|
return $app;
|
||||||
|
|
|
@ -1,12 +1,26 @@
|
||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Flarum\Console\GenerateExtensionCommand;
|
||||||
|
use Flarum\Console\UpgradeCommand;
|
||||||
|
use Flarum\Install\Console\InstallCommand;
|
||||||
|
use Symfony\Component\Console\Application;
|
||||||
|
|
||||||
$app = require_once __DIR__.'/bootstrap.php';
|
$app = require_once __DIR__.'/bootstrap.php';
|
||||||
|
|
||||||
$console = new \Symfony\Component\Console\Application('Flarum', '0.1.0-beta');
|
$console = new Application('Flarum', $app::VERSION);
|
||||||
|
|
||||||
$console->add(new \Flarum\Install\Console\InstallCommand($app));
|
$console->add(new InstallCommand($app));
|
||||||
$console->add(new \Flarum\Console\UpgradeCommand($app));
|
$console->add(new UpgradeCommand($app));
|
||||||
$console->add(new \Flarum\Console\GenerateExtensionCommand($app));
|
$console->add(new GenerateExtensionCommand($app));
|
||||||
|
|
||||||
exit($console->run());
|
exit($console->run());
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
*
|
|
||||||
!.gitignore
|
|
|
@ -70,26 +70,26 @@ else
|
||||||
echo "source ~/.aliases" >> ~/.bashrc
|
echo "source ~/.aliases" >> ~/.bashrc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Set up environment files and database ###
|
|
||||||
cp /vagrant/system/.env.example /vagrant/system/.env
|
|
||||||
mysql -u root -proot -e 'create database flarum'
|
mysql -u root -proot -e 'create database flarum'
|
||||||
|
|
||||||
### Setup flarum/core and install dependencies ###
|
### Setup flarum/core and install dependencies ###
|
||||||
cd /vagrant/system/core
|
cd /vagrant/flarum/core
|
||||||
composer install --prefer-dist
|
composer install --prefer-dist
|
||||||
cd /vagrant/system
|
|
||||||
|
cd /vagrant/flarum
|
||||||
composer install --prefer-dist
|
composer install --prefer-dist
|
||||||
composer dump-autoload
|
composer dump-autoload
|
||||||
|
|
||||||
cd /vagrant/system/core/js
|
cd /vagrant/flarum/core/js
|
||||||
bower install
|
bower install
|
||||||
cd /vagrant/system/core/js/forum
|
|
||||||
|
cd /vagrant/flarum/core/js/forum
|
||||||
npm install
|
npm install
|
||||||
gulp
|
gulp
|
||||||
cd /vagrant/system/core/js/admin
|
|
||||||
|
cd /vagrant/flarum/core/js/admin
|
||||||
npm install
|
npm install
|
||||||
gulp
|
gulp
|
||||||
|
|
||||||
cd /vagrant/system
|
cd /vagrant/system
|
||||||
#php flarum vendor:publish
|
|
||||||
php flarum install --defaults
|
php flarum install --defaults
|
||||||
|
|
30
index.php
30
index.php
|
@ -1,28 +1,41 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
use Flarum\Core;
|
use Flarum\Core;
|
||||||
|
use Flarum\Forum\Middleware\HandleErrors;
|
||||||
|
use Franzl\Middleware\Whoops\Middleware as WhoopsMiddleware;
|
||||||
use Zend\Diactoros\Server;
|
use Zend\Diactoros\Server;
|
||||||
use Zend\Stratigility\MiddlewarePipe;
|
use Zend\Stratigility\MiddlewarePipe;
|
||||||
|
|
||||||
// Instantiate the application, register providers etc.
|
|
||||||
$app = require __DIR__.'/flarum/bootstrap.php';
|
$app = require __DIR__.'/flarum/bootstrap.php';
|
||||||
|
|
||||||
|
// If Flarum's configuration exists, then we can assume that installation has
|
||||||
|
// been completed. We will set up a middleware pipe to route the request through
|
||||||
|
// to one of the main forum actions.
|
||||||
if ($app->bound('flarum.config')) {
|
if ($app->bound('flarum.config')) {
|
||||||
$app->register('Flarum\Forum\ForumServiceProvider');
|
$app->register('Flarum\Forum\ForumServiceProvider');
|
||||||
|
|
||||||
// Build a middleware pipeline for Flarum
|
|
||||||
$flarum = new MiddlewarePipe();
|
$flarum = new MiddlewarePipe();
|
||||||
$flarum->pipe($app->make('Flarum\Forum\Middleware\LoginWithCookie'));
|
$flarum->pipe($app->make('Flarum\Forum\Middleware\LoginWithCookie'));
|
||||||
$flarum->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
|
$flarum->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
|
||||||
|
|
||||||
$basePath = parse_url(Core::config('base_url'), PHP_URL_PATH);
|
$basePath = parse_url(Core::config('base_url'), PHP_URL_PATH);
|
||||||
$flarum->pipe($basePath, $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.forum.routes')]));
|
$router = $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.forum.routes')]);
|
||||||
|
|
||||||
|
$flarum->pipe($basePath, $router);
|
||||||
|
|
||||||
// Handle errors
|
|
||||||
if (Core::inDebugMode()) {
|
if (Core::inDebugMode()) {
|
||||||
$flarum->pipe(new \Franzl\Middleware\Whoops\Middleware());
|
$flarum->pipe(new WhoopsMiddleware());
|
||||||
} else {
|
} else {
|
||||||
$flarum->pipe(new \Flarum\Forum\Middleware\HandleErrors(base_path('error')));
|
$flarum->pipe(new HandleErrors(base_path('error')));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$app->register('Flarum\Install\InstallServiceProvider');
|
$app->register('Flarum\Install\InstallServiceProvider');
|
||||||
|
@ -30,8 +43,9 @@ if ($app->bound('flarum.config')) {
|
||||||
$flarum = new MiddlewarePipe();
|
$flarum = new MiddlewarePipe();
|
||||||
|
|
||||||
$basePath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
$basePath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||||
$flarum->pipe($basePath, $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.install.routes')]));
|
$router = $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.install.routes')]);
|
||||||
$flarum->pipe(new \Franzl\Middleware\Whoops\Middleware());
|
$flarum->pipe($basePath, $router);
|
||||||
|
$flarum->pipe(new WhoopsMiddleware());
|
||||||
}
|
}
|
||||||
|
|
||||||
$server = Server::createServer(
|
$server = Server::createServer(
|
||||||
|
|
Loading…
Reference in New Issue