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

3
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.
@ -296,7 +295,7 @@ Vagrant.configure("2") do |config|
config.vm.provision "shell", path: "#{github_url}/scripts/composer.sh", privileged: false, args: composer_packages.join(" ")
# Provision Laravel
#config.vm.provision "shell", path: "#{github_url}/scripts/laravel.sh", privileged: false, args: [server_ip, laravel_root_folder, public_folder, laravel_version]
# config.vm.provision "shell", path: "#{github_url}/scripts/laravel.sh", privileged: false, args: [server_ip, laravel_root_folder, public_folder, laravel_version]
# Provision Symfony
# config.vm.provision "shell", path: "#{github_url}/scripts/symfony.sh", privileged: false, args: [server_ip, symfony_root_folder, public_folder]

View File

@ -1,37 +1,46 @@
<?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(
$admin,
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
$admin,
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
);
$server->listen();

35
api.php
View File

@ -1,37 +1,46 @@
<?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(
$api,
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
$api,
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
);
$server->listen();

View File

@ -1,27 +1,43 @@
<?php
define('LARAVEL_START', microtime(true));
require __DIR__.'/vendor/autoload.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.
*/
// Temp while franzliedke/studio doesn't autoload files
if (file_exists(__DIR__.'/core')) {
require __DIR__.'/core/src/helpers.php';
require __DIR__.'/core/vendor/swiftmailer/swiftmailer/lib/swift_required.php';
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';
// 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,9 +69,8 @@ $app->instance('config', $config = new \Illuminate\Config\Repository([
],
]));
// ConfigureLogging
$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->setFormatter(new \Monolog\Formatter\LineFormatter(null, null, true, true));
$logger->pushHandler($handler);
@ -63,13 +78,7 @@ $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) {
$app->singleton('cache', function ($app) {
$store = new FileStore(new Filesystem(), storage_path('framework/cache'));
$repository = new Repository($store);
$repository->setEventDispatcher($app->make('events'));
@ -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,20 +1,20 @@
{
"name": "flarum/flarum",
"description": "The Flarum forum skeleton.",
"keywords": ["forum", "flarum"],
"license": "MIT",
"type": "project",
"require": {
"illuminate/container": "5.1.*",
"monolog/monolog": "^1.16.0",
"zendframework/zend-stratigility": "^1.1",
"franzl/whoops-middleware": "dev-master",
"flarum/core": "0.1.x@dev"
},
"require-dev": {
"franzl/studio": "1.0.x@dev"
},
"config": {
"preferred-install": "dist"
}
"name": "flarum/flarum",
"description": "The Flarum forum skeleton.",
"keywords": ["forum", "flarum"],
"license": "MIT",
"type": "project",
"require": {
"illuminate/container": "5.1.*",
"monolog/monolog": "^1.16.0",
"zendframework/zend-stratigility": "^1.1",
"franzl/whoops-middleware": "dev-master",
"flarum/core": "0.1.x@dev"
},
"require-dev": {
"franzl/studio": "1.0.x@dev"
},
"config": {
"preferred-install": "dist"
}
}

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,17 +43,18 @@ 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(
$flarum,
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
$flarum,
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
);
$server->listen();