-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- initial commit: structure, db, simple usermanagement, some console …
…commands
- Loading branch information
0 parents
commit 1e0268f
Showing
47 changed files
with
1,668 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
config.php | ||
parameters.php | ||
logs/* | ||
cache/* | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[submodule "vendor/Silex"] | ||
path = vendor/Silex | ||
url = http://github.com/fabpot/Silex.git | ||
[submodule "vendor/Twig"] | ||
path = vendor/Twig | ||
url = http://github.com/fabpot/Twig.git | ||
[submodule "vendor/Symfony/Bridge/Twig"] | ||
path = vendor/Symfony/Bridge/Twig | ||
url = https://github.com/symfony/TwigBridge.git | ||
[submodule "vendor/Twig-extensions"] | ||
path = vendor/Twig-extensions | ||
url = https://github.com/fabpot/Twig-extensions.git | ||
[submodule "vendor/dbal"] | ||
path = vendor/dbal | ||
url = http://github.com/doctrine/dbal.git | ||
[submodule "vendor/common"] | ||
path = vendor/common | ||
url = http://github.com/doctrine/common.git | ||
[submodule "vendor/monolog"] | ||
path = vendor/monolog | ||
url = http://github.com/Seldaek/monolog | ||
[submodule "vendor/Symfony/Component/Form"] | ||
path = vendor/Symfony/Component/Form | ||
url = http://github.com/symfony/Form.git | ||
[submodule "vendor/Symfony/Component/Validator"] | ||
path = vendor/Symfony/Component/Validator | ||
url = http://github.com/symfony/Validator.git | ||
[submodule "vendor/Symfony/Component/Console"] | ||
path = vendor/Symfony/Component/Console | ||
url = git://github.com/symfony/Console.git | ||
[submodule "vendor/Pimple"] | ||
path = vendor/Pimple | ||
url = https://github.com/fabpot/Pimple.git | ||
[submodule "vendor/Symfony/Component/ClassLoader"] | ||
path = vendor/Symfony/Component/ClassLoader | ||
url = git://github.com/symfony/ClassLoader.git | ||
[submodule "vendor/Symfony/Component/HttpKernel"] | ||
path = vendor/Symfony/Component/HttpKernel | ||
url = https://github.com/symfony/HttpKernel.git | ||
[submodule "vendor/Symfony/Component/EventDispatcher"] | ||
path = vendor/Symfony/Component/EventDispatcher | ||
url = https://github.com/symfony/EventDispatcher.git | ||
[submodule "vendor/Symfony/Component/HttpFoundation"] | ||
path = vendor/Symfony/Component/HttpFoundation | ||
url = https://github.com/symfony/HttpFoundation.git | ||
[submodule "vendor/Symfony/Component/Routing"] | ||
path = vendor/Symfony/Component/Routing | ||
url = https://github.com/symfony/Routing.git | ||
[submodule "vendor/Symfony/Component/Translation"] | ||
path = vendor/Symfony/Component/Translation | ||
url = git://github.com/symfony/Translation.git | ||
[submodule "web/assets/bootstrap"] | ||
path = web/assets/bootstrap | ||
url = https://github.com/twitter/bootstrap.git | ||
[submodule "vendor/swiftmailer"] | ||
path = vendor/swiftmailer | ||
url = https://github.com/swiftmailer/swiftmailer.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# General Info | ||
|
||
This project allows you to see what is your daily employees' satisfaction at work. | ||
This is a pet project that aims to know more Silex and it interactions with Sf2 Components. | ||
|
||
# Installation | ||
|
||
``` | ||
cp app/config/config.php.dist app/config/config.php | ||
chmod -R 777 app/logs | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require_once __DIR__.'/../vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php'; | ||
|
||
use Symfony\Component\ClassLoader\UniversalClassLoader; | ||
|
||
$loader = new UniversalClassLoader(); | ||
$loader->registerNamespaces(array( | ||
'Symfony' => __DIR__.'/../vendor', | ||
'Silex' => __DIR__.'/../vendor/Silex/src', | ||
'Employness' => __DIR__.'/../src', | ||
)); | ||
$loader->registerPrefixes(array( | ||
'Pimple' => __DIR__.'/../vendor/Pimple/lib', | ||
'Twig_Extensions_' => __DIR__.'/../vendor/Twig-extensions/lib', | ||
'Twig_' => __DIR__.'/../vendor/Twig/lib', | ||
)); | ||
$loader->register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
require_once __DIR__.'/autoload.php'; | ||
|
||
use Employness\Application; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | ||
|
||
$app = new Application(); | ||
$config = require __DIR__.'/config/config.php'; | ||
|
||
// console env gestion | ||
if (isset($_SERVER['ENV']) && in_array($_SERVER['ENV'], array('dev', 'test', 'prod'))) { | ||
$config['env'] = $_SERVER['ENV']; | ||
} | ||
$app['debug'] = $config['env'] == 'prod' ? false : true; | ||
|
||
/** | ||
* Load Extensions / Services | ||
**/ | ||
$app->register(new Silex\Provider\UrlGeneratorServiceProvider()); | ||
$app->register(new Silex\Provider\SessionServiceProvider()); | ||
$app->register(new Silex\Provider\MonologServiceProvider(), array( | ||
'monolog.logfile' => __DIR__.'/logs/'.$config['env'].'.log', | ||
'monolog.class_path' => __DIR__.'/../vendor/monolog/src', | ||
)); | ||
$app->register(new Silex\Provider\TwigServiceProvider(), array( | ||
'twig.path' => array( | ||
__DIR__.'/../src/Employness/Resources/views', | ||
__DIR__.'/../vendor/Symfony/Bridge/Twig/Resources/views/Form', | ||
), | ||
'twig.class_path' => __DIR__.'/../vendor/Twig/lib', | ||
)); | ||
$app->register(new Silex\Provider\SymfonyBridgesServiceProvider(), array( | ||
'symfony_bridges.class_path' => __DIR__ . '/../vendor/symfony/src' | ||
)); | ||
$app->register(new Silex\Provider\FormServiceProvider(), array( | ||
'form.class_path' => __DIR__ . '/../vendor/symfony/src' | ||
)); | ||
$app->register(new Silex\Provider\TranslationServiceProvider(), array( | ||
'locale_fallback' => 'en', | ||
'translation.class_path' => __DIR__.'/../vendor/symfony/src', | ||
)); | ||
$app->register(new Silex\Provider\SwiftmailerServiceProvider(), array( | ||
'swiftmailer.class_path' => __DIR__.'/../vendor/swiftmailer/lib/classes', | ||
)); | ||
$app->register(new Silex\Provider\DoctrineServiceProvider(), array( | ||
'db.options' => $config['db'][$config['env']], | ||
'db.dbal.class_path' => __DIR__.'/../vendor/dbal/lib', | ||
'db.common.class_path' => __DIR__.'/../vendor/common/lib', | ||
)); | ||
|
||
// be sure not to acccess db config elsewhere | ||
unset($config['db']); | ||
|
||
$app['db.logger'] = function() use($app) { | ||
return new \Blog\DB\Logger($app['monolog']); | ||
}; | ||
|
||
/** | ||
* Load Translations | ||
**/ | ||
$app['translator.messages'] = require_once __DIR__.'/../src/Employness/Resources/translations/translations.php'; | ||
if (!isset($app['translator.messages'][$config['locale']])) { | ||
die('You must provide a valid locale in your config file'); | ||
} | ||
$app['locale'] = $config['locale']; | ||
|
||
/** | ||
* Load Controllers | ||
**/ | ||
require __DIR__.'/../src/Employness/Controller/FrontendController.php'; | ||
require __DIR__.'/../src/Employness/Controller/BackendController.php'; | ||
|
||
/** | ||
* Usermanagement & session | ||
**/ | ||
$app->before(function(Request $request) use ($app) | ||
{ | ||
// User management | ||
$app['session']->start(); | ||
$app['user'] = $request->getSession()->get('user', false); | ||
|
||
if (preg_match('/^admin/', $request->attributes->get('_route'))) { | ||
$sql = "SELECT * FROM employness_users WHERE LOWER(email) = ? AND password = ?"; | ||
|
||
if (false === $app['user'] || false === $user = $app['db']->fetchAssoc($sql, array($app['user']['email'], $app['user']['password']))) { | ||
$request->getSession()->setFlash('warning', $app['translator']->trans('you_must_be_logged')); | ||
return $app->redirect($app['url_generator']->generate( | ||
'login', | ||
array('redirect' => base64_encode($app['url_generator']->generate('admin'))) | ||
)); | ||
} elseif ($user['admin'] == 0) { | ||
throw new AccessDeniedHttpException('must_be_admin'); | ||
} | ||
} | ||
}); | ||
|
||
/** | ||
* Custom error pages | ||
**/ | ||
$app->error(function (Exception $e) use ($app) | ||
{ | ||
if ($e instanceof NotFoundHttpException) { | ||
return $app['twig']->render('Default/error.html.twig', array('code' => 404, 'message' => $e->getMessage())); | ||
} elseif ($e instanceof AccessDeniedHttpException) { | ||
return $app['twig']->render('Default/error.html.twig', array('code' => 403, 'message' => $e->getMessage())); | ||
} | ||
|
||
$code = ($e instanceof HttpException) ? $e->getStatusCode() : 500; | ||
return $app['twig']->render('Default/error.html.twig', array('code' => $code, 'message' => $e->getMessage())); | ||
}); | ||
|
||
return $app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
return array( | ||
// site settings | ||
'env' => 'dev', // (prod|dev|test) | ||
'locale' => 'en', // (en|fr) | ||
|
||
// database settings | ||
'db' => array( | ||
'prod' => array( | ||
'driver' => 'pdo_mysql', | ||
'dbname' => 'employness_prod', | ||
'host' => 'localhost', | ||
'user' => 'root', | ||
'password' => 'root', | ||
), | ||
'dev' => array( | ||
'driver' => 'pdo_mysql', | ||
'dbname' => 'employness_prod', | ||
'host' => 'localhost', | ||
'user' => 'root', | ||
'password' => 'root', | ||
), | ||
'test' => array( | ||
'driver' => 'pdo_mysql', | ||
'dbname' => 'employness_prod', | ||
'host' => 'localhost', | ||
'user' => 'root', | ||
'password' => 'root', | ||
), | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
$_SERVER['ENV'] = 'dev'; | ||
|
||
if (false !== $pos = array_search('-e', $argv) || false !== $pos = array_search('--env', $argv)) { | ||
$_SERVER['ENV'] = $argv[$pos]; | ||
} | ||
|
||
$app = require __DIR__.'/bootstrap.php'; | ||
$application = new Employness\Console\Application($app); | ||
$application->run(); |
Empty file.
Oops, something went wrong.