Udpate to support dev/prod env

This commit is contained in:
Laurent Cozic committed 2017-01-09 22:15:02 +01:00
1 parent 11115077d5
commit 228831bf23
9 files changed
+29 -13

No files matched your search

+5 -1
View File
@@ -1,4 +1,6 @@
/app/config/parameters.yml
/app/config/parameters_dev.yml
/app/config/parameters_prod.yml
/build/
/phpunit.xml
/var/*
@@ -25,4 +27,6 @@ QtClient/data/
app/data/uploads/
!app/data/uploads/.gitkeep
sparse_test.php
INFO.md
INFO.md
/web/env.php
sync_staging.sh
+2 -1
View File
@@ -7,7 +7,8 @@ services:
app.eloquent:
class: AppBundle\Eloquent
arguments: ['@app.mime_types', '@app.paths']
# arguments: [%kernel.environment%, '@app.mime_types', '@app.paths']
arguments: [%database%, '@app.mime_types', '@app.paths']
twig.exception_listener:
class: stdObject
Executable
+1
View File
@@ -0,0 +1 @@
<?php return 'dev'; // return 'prod';
+7 -2
View File
@@ -47,14 +47,19 @@ abstract class ApiController extends Controller {
$s = $this->session();
// TODO: find less hacky way to get request path
// TODO: find less hacky way to get request path and method
$requestPath = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$requestPath = ltrim($requestPath, '/');
$requestPath = rtrim($requestPath, '?');
$method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
$sessionRequired = true;
if ($method == 'POST' && $requestPath == 'sessions') $sessionRequired = false;
if ($method == 'POST' && $requestPath == 'users') $sessionRequired = false;
// TODO: to keep it simple, only respond to logged in users, but in theory some data
// could be public.
if ($requestPath != 'sessions' && (!$s || !$this->user())) throw new UnauthorizedException('A session and user are required');
if ($sessionRequired && (!$s || !$this->user())) throw new UnauthorizedException('A session and user are required');
BaseModel::setClientId($s ? $s->client_id : 0);
}
+6 -7
View File
@@ -6,20 +6,19 @@ class Eloquent {
private $capsule_ = null;
public function __construct($mimeTypes, $paths) {
public function __construct($dbParams, $mimeTypes, $paths) {
$this->capsule_ = new \Illuminate\Database\Capsule\Manager();
$this->capsule_->addConnection([
$dbParamsDefaults = array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'notes',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
);
$dbParams = array_merge($dbParamsDefaults, $dbParams);
$this->capsule_->addConnection($dbParams);
$this->capsule_->bootEloquent();
// In order to keep things lightweight, the models aren't part of Symfony dependency
+1 -1
View File
@@ -83,7 +83,7 @@ class Change extends BaseModel {
});
foreach ($output as $k => $syncItem) {
if ($syncItem['item']) {
if (isset($syncItem['item'])) {
$item = $syncItem['item']->toPublicArray();
if ($syncItem['type'] == 'update') {
foreach ($item as $field => $value) {
Executable
+4
View File
@@ -0,0 +1,4 @@
app.engine=php
app.engine.version=7.0
http.firewall=none
environment=development
+3 -1
View File
@@ -6,7 +6,9 @@ use Symfony\Component\HttpFoundation\Request;
$loader = require __DIR__.'/../app/autoload.php';
include_once __DIR__.'/../var/bootstrap.php.cache';
$kernel = new AppKernel('prod', false);
$env = require 'env.php';
$kernel = new AppKernel($env, false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
Executable → Regular
View File
File mode changed.