Skip to content

Commit

Permalink
release 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
trungpv1601 committed Jul 13, 2017
1 parent 34ac055 commit bfb8172
Show file tree
Hide file tree
Showing 7,316 changed files with 416 additions and 747,511 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
10 changes: 6 additions & 4 deletions app/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Exception;
use Symfony\Component\HttpFoundation\Response;
use League\Plates\Engine;
use Medoo\Medoo;

/**
* Handles all requests to /.
Expand All @@ -12,17 +13,18 @@
*/
class IndexController
{
/** @var Twig_Environment */
private $view;
private $database;

/**
* IndexController, constructed by the container
*
* @param Twig_Environment $twig
* @param Engine $view
*/
public function __construct(Engine $view)
public function __construct(Engine $view, Medoo $database)
{
$this->view = $view;
$this->database = $database;
}

/**
Expand All @@ -32,7 +34,7 @@ public function __construct(Engine $view)
*/
public function index()
{
return new Response($this->view->render('index', ['name' => 'Jonathan']));
return new Response($this->view->render('index'));
}

/**
Expand Down
31 changes: 25 additions & 6 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

/*
* Container setup
* http://container.thephpleague.com/
*/
$container = new Container();
// Native PHP template http://platesphp.com/
$container
->add('League\Plates\Engine', new \League\Plates\Engine(__DIR__ . "/../views"));
$container
Expand All @@ -30,17 +32,16 @@
new ReflectionContainer()
);
// Get Container App\Controllers\ErrorController
$errorController = $container->get('App\Controllers\ErrorController');

$errorController = $container->get('App\Controllers\ErrorController');

/*
* Dotenv initialization
* https://github.com/vlucas/phpdotenv
*/
if (file_exists(__DIR__ . '/../.env') !== true) {
// Response::create('Missing .env file (please copy .env.example).', Response::HTTP_INTERNAL_SERVER_ERROR)
// ->prepare($request)
// ->send();
$errorController->page500('Missing .env file (please copy .env.example).');
Response::create('Missing .env file (please copy .env.example).', Response::HTTP_INTERNAL_SERVER_ERROR)
->prepare($request)
->send();
return;
}
$dotenv = new Dotenv\Dotenv(__DIR__ . '/../');
Expand All @@ -49,6 +50,7 @@

/*
* Error handler
* https://github.com/filp/whoops
*/
$whoops = new Run;
if (getenv('APP_DEBUG') === 'true') {
Expand All @@ -69,8 +71,25 @@ function () use ($errorController) {
}
$whoops->register();


/*
* Database
* https://medoo.in/api/new
*/
$container
->add('Medoo\Medoo')
->withArgument([
'database_type' => getenv('DB_CONNECTION') ? getenv('DB_CONNECTION') : 'mysql',
'server' => getenv('DB_HOST') ? getenv('DB_HOST') : 'localhost',
'port' => getenv('DB_PORT') ? getenv('DB_PORT') : 3306,
'database_name' => getenv('DB_DATABASE') ? getenv('DB_DATABASE') : 'name',
'username' => getenv('DB_USERNAME') ? getenv('DB_USERNAME') : 'your_username',
'password' => getenv('DB_PASSWORD') ? getenv('DB_PASSWORD') : ''
]);

/*
* Routes
* https://github.com/nikic/FastRoute
*/
$dispatcher = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) {
$routes = require __DIR__ . '/../routes.php';
Expand Down
11 changes: 0 additions & 11 deletions public/adminlte/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions public/adminlte/.npmignore

This file was deleted.

Loading

0 comments on commit bfb8172

Please sign in to comment.