Clean up, add header comments

pull/9/head
Toby Zerner 2015-08-26 17:13:18 +09:30
parent 5aa4530447
commit dd6cb2f6ce
10 changed files with 146 additions and 96 deletions

1
Vagrantfile vendored
View File

@ -8,7 +8,6 @@ github_branch = "1.3.0"
github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"
# Server Configuration
hostname = "flarum.dev"
# Set a local private network IP address.

View File

@ -1,28 +1,37 @@
<?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\Forum\Middleware\HandleErrors;
use Franzl\Middleware\Whoops\Middleware as WhoopsMiddleware;
use Zend\Diactoros\Server;
use Zend\Stratigility\MiddlewarePipe;
// Instantiate the application, register providers etc.
$app = require __DIR__.'/flarum/bootstrap.php';
// Set up everything we need for the frontend
$app->register('Flarum\Admin\AdminServiceProvider');
// Build a middleware pipeline for Flarum
$admin = new MiddlewarePipe();
$admin->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
$admin->pipe($app->make('Flarum\Admin\Middleware\LoginWithCookieAndCheckAdmin'));
$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()) {
$admin->pipe(new \Franzl\Middleware\Whoops\Middleware());
$admin->pipe(new WhoopsMiddleware());
} else {
$admin->pipe(new \Flarum\Forum\Middleware\HandleErrors(base_path('error')));
$admin->pipe(new HandleErrors(base_path('error')));
}
$server = Server::createServer(

23
api.php
View File

@ -1,28 +1,37 @@
<?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 Franzl\Middleware\Whoops\Middleware as WhoopsMiddleware;
use Zend\Diactoros\Server;
use Zend\Stratigility\MiddlewarePipe;
// Instantiate the application, register providers etc.
$app = require __DIR__.'/flarum/bootstrap.php';
// Set up everything we need for the API
$app->register('Flarum\Api\ApiServiceProvider');
// Build a middleware pipeline for the API
$api = new MiddlewarePipe();
$api->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
$api->pipe($app->make('Flarum\Api\Middleware\LoginWithHeader'));
$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()) {
$api->pipe(new \Franzl\Middleware\Whoops\Middleware());
$api->pipe(new WhoopsMiddleware());
} else {
$api->pipe(new \Flarum\Api\Middleware\JsonApiErrors());
$api->pipe(new JsonApiErrors());
}
$server = Server::createServer(

View File

@ -1,27 +1,43 @@
<?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';
// 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')) {
require __DIR__ . '/core/src/helpers.php';
require __DIR__ . '/core/vendor/swiftmailer/swiftmailer/lib/swift_required.php';
}
$app = new Flarum\Core\Application(
realpath(__DIR__)
);
$app = new Application(realpath(__DIR__));
$app->instance('path.public', __DIR__.'/..');
Illuminate\Container\Container::setInstance($app);
// LoadConfiguration
if (file_exists($configFile = __DIR__.'/../config.php')) {
$app->instance('flarum.config', include $configFile);
}
$app->instance('config', $config = new \Illuminate\Config\Repository([
$app->instance('config', $config = new ConfigRepository([
'view' => [
'paths' => [
realpath(base_path('resources/views'))
@ -53,7 +69,6 @@ $app->instance('config', $config = new \Illuminate\Config\Repository([
],
]));
// ConfigureLogging
$logger = new Monolog\Logger($app->environment());
$logPath = $app->storagePath() . '/logs/flarum.log';
$handler = new \Monolog\Handler\StreamHandler($logPath, Monolog\Logger::DEBUG);
@ -63,12 +78,6 @@ $logger->pushHandler($handler);
$app->instance('log', $logger);
$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) {
$store = new FileStore(new Filesystem(), storage_path('framework/cache'));
$repository = new Repository($store);
@ -77,7 +86,6 @@ $app->singleton('cache', function($app) {
});
$app->alias('cache', 'Illuminate\Contracts\Cache\Repository');
// RegisterProviders
$serviceProviders = [
'Flarum\Core\DatabaseServiceProvider',
'Flarum\Core\Settings\SettingsServiceProvider',
@ -114,7 +122,6 @@ if (Core::isInstalled()) {
$app->register(new \Flarum\Support\ExtensionsServiceProvider($app));
}
// BootProviders
$app->boot();
return $app;

View File

@ -1,12 +1,26 @@
#!/usr/bin/env 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';
$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 \Flarum\Console\UpgradeCommand($app));
$console->add(new \Flarum\Console\GenerateExtensionCommand($app));
$console->add(new InstallCommand($app));
$console->add(new UpgradeCommand($app));
$console->add(new GenerateExtensionCommand($app));
exit($console->run());

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -70,26 +70,26 @@ else
echo "source ~/.aliases" >> ~/.bashrc
fi
### Set up environment files and database ###
cp /vagrant/system/.env.example /vagrant/system/.env
mysql -u root -proot -e 'create database flarum'
### Setup flarum/core and install dependencies ###
cd /vagrant/system/core
cd /vagrant/flarum/core
composer install --prefer-dist
cd /vagrant/system
cd /vagrant/flarum
composer install --prefer-dist
composer dump-autoload
cd /vagrant/system/core/js
cd /vagrant/flarum/core/js
bower install
cd /vagrant/system/core/js/forum
cd /vagrant/flarum/core/js/forum
npm install
gulp
cd /vagrant/system/core/js/admin
cd /vagrant/flarum/core/js/admin
npm install
gulp
cd /vagrant/system
#php flarum vendor:publish
php flarum install --defaults

View File

@ -1,28 +1,41 @@
<?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\Forum\Middleware\HandleErrors;
use Franzl\Middleware\Whoops\Middleware as WhoopsMiddleware;
use Zend\Diactoros\Server;
use Zend\Stratigility\MiddlewarePipe;
// Instantiate the application, register providers etc.
$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')) {
$app->register('Flarum\Forum\ForumServiceProvider');
// Build a middleware pipeline for Flarum
$flarum = new MiddlewarePipe();
$flarum->pipe($app->make('Flarum\Forum\Middleware\LoginWithCookie'));
$flarum->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
$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()) {
$flarum->pipe(new \Franzl\Middleware\Whoops\Middleware());
$flarum->pipe(new WhoopsMiddleware());
} else {
$flarum->pipe(new \Flarum\Forum\Middleware\HandleErrors(base_path('error')));
$flarum->pipe(new HandleErrors(base_path('error')));
}
} else {
$app->register('Flarum\Install\InstallServiceProvider');
@ -30,8 +43,9 @@ if ($app->bound('flarum.config')) {
$flarum = new MiddlewarePipe();
$basePath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$flarum->pipe($basePath, $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.install.routes')]));
$flarum->pipe(new \Franzl\Middleware\Whoops\Middleware());
$router = $app->make('Flarum\Http\RouterMiddleware', ['routes' => $app->make('flarum.install.routes')]);
$flarum->pipe($basePath, $router);
$flarum->pipe(new WhoopsMiddleware());
}
$server = Server::createServer(