Skip to content

Commit

Permalink
Adapt for upstream laravel structure
Browse files Browse the repository at this point in the history
  • Loading branch information
yukoff committed Jul 23, 2017
1 parent 9ff0d4c commit 0beffd0
Show file tree
Hide file tree
Showing 174 changed files with 6,642 additions and 11,839 deletions.
40 changes: 40 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}

/**
* Register the Closure based commands for the application.
*
* @return void
*/
// protected function commands()
// {
// require base_path('routes/console.php');
// }
}
53 changes: 53 additions & 0 deletions artisan
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

require __DIR__.'/bootstrap/autoload.php';
//require_once __DIR__.'/library/config.php';
//require_once __DIR__.'/common.php';
$app = require_once __DIR__.'/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/

/* @var App\Console\Kernel $kernel */
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);

/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/

$kernel->terminate($input, $status);

exit($status);
189 changes: 189 additions & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<?php
/**
* TorrentPier – Bull-powered BitTorrent tracker engine
*
* @copyright Copyright (c) 2005-2017 TorrentPier (https://torrentpier.com)
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
*/

use Dotenv\Dotenv;
use Dotenv\Exception\InvalidPathException;
use Illuminate\Cache\CacheManager;
use Illuminate\Config\Repository;
use Illuminate\Container\Container;
use Illuminate\Database\Capsule\Manager;
use Illuminate\Database\Events\StatementPrepared;
use Illuminate\Events\Dispatcher;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Application;
use Illuminate\Translation\FileLoader;
use Illuminate\Translation\Translator;
use Symfony\Component\Finder\Finder;

try {
(new Dotenv(__DIR__.'/..'))->load();
} catch (InvalidPathException $e) {
throw $e;
}

/*
* Create The Application
* @var Application $app
*/
$app = new Application(
realpath(__DIR__.'/../')
);
//$app = new Container();
//Container::setInstance($app);
//$app->instance('app', $app);
//$app->instance(Container::class, $app);

$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
// in future to overrive use
App\Console\Kernel::class
// Illuminate\Foundation\Console\Kernel::class
);

$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
// in future to override use
//App\Exceptions\Handler::class
Illuminate\Foundation\Exceptions\Handler::class
);

/**
* Service Container
* @var Container $container
*/
//$container = new Container;
//Container::setInstance($container);

/**
* Events
*/
$app->instance('events', new Dispatcher);

/**
* Database
*/
$app->singleton('db', function ($app) {
/** @var Manager $capsule */
$capsule = new Manager;

$capsule->addConnection([
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'torrentpier'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'pass'),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
]);

$capsule->setEventDispatcher($app['events']);
$capsule->setAsGlobal();
$capsule->bootEloquent();

return $capsule;
});
$app->instance(Manager::class, $app->make('db'));

/**
* Database setFetchMode
* @var Dispatcher $dispatcher
*/
$dispatcher = $app->make('events');
$dispatcher->listen(StatementPrepared::class, function ($event) {
$event->statement->setFetchMode(PDO::FETCH_ASSOC);
});

/**
* Request
*/
$app->instance('request', Illuminate\Http\Request::capture());

/**
* Filesystem
*/
$app->instance('files', new Filesystem);

/**
* Config
*/
$app->singleton('config', function () {
/** @var Repository $config */
$config = new Repository;

$files = [];

$configPath = __DIR__ . '/config';

/** @noinspection ForeachSourceInspection */
foreach (Finder::create()->files()->name('*.php')->in($configPath) as $file) {
/** @var \SplFileInfo $file */
$configFile = $file->getRealPath();
$files[basename($configFile, '.php')] = $configFile;
}

foreach ($files as $key => $path) {
if ($key === 'tp') {
// if (!$cfg = OLD_CACHE('bb_config')->get('config_bb_config')) {
$cfg = [];
foreach (Manager::table('bb_config')->get()->toArray() as $row) {
$cfg[$row['config_name']] = $row['config_value'];
}
// }
/** @noinspection PhpIncludeInspection */
$config->set($key, array_merge(require $path, $cfg));
} else {
/** @noinspection PhpIncludeInspection */
$config->set($key, require $path);
}
}

$config->set('cache', [
'default' => 'file',
'stores' => [
'file' => [
'driver' => 'file',
'path' => $config->get('tp.cache.db_dir'),
],
],
]);

return $config;
});

/**
* Cache
*/
$app->singleton('cache', function ($app) {
/** @var CacheManager $cache */
$cache = new CacheManager($app);

return $cache->driver();
});

/**
* Localization
*/
$app->singleton('translator', function ($app) {
$loader = $app['translation.loader'];
$locale = $app['config']['app.locale'];

$trans = new Translator($loader, $locale);

$trans->setFallback($app['config']['app.fallback_locale']);

return $trans;
});

$app->singleton('translation.loader', function ($app) {
return new FileLoader($app['files'], __DIR__ . '/resources/lang');
});

return $app;
17 changes: 17 additions & 0 deletions bootstrap/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so we do not have to manually load any of
| our application's PHP classes. It just feels great to relax.
|
*/

require __DIR__.'/../vendor/autoload.php';
2 changes: 2 additions & 0 deletions bootstrap/cache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
33 changes: 27 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,39 @@
"symfony/dotenv": "^3.3",
"symfony/var-dumper": "^3.3"
},
"require-dev": {
"doctrine/dbal": "^2.5",
"laravel-doctrine/migrations": "^1.1",
"laravel-doctrine/orm": "^1.3",
"laravel/framework": "^5.4",
"predis/predis": "^1.1",
"symfony/yaml": "^3.3"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app",
"Database\\Types\\": "database/types",
"TorrentPier\\": "src/"
}
},
"scripts": {
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"minimum-stability": "stable",
"prefer-stable": true,
"require-dev": {
"doctrine/migrations": "^1.5",
"doctrine/orm": "^2.5",
"doctrine/annotations": "^1.4",
"doctrine/cache": "^1.6",
"jdorn/sql-formatter": "^1.2"
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Loading

0 comments on commit 0beffd0

Please sign in to comment.