Skip to content

Instantly share code, notes, and snippets.

@filhodanuvem
Created July 3, 2012 00:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filhodanuvem/3036556 to your computer and use it in GitHub Desktop.
Save filhodanuvem/3036556 to your computer and use it in GitHub Desktop.
FaceApp scaffold
{
"name" : "NomeDoProjeto",
"autoload" : {
"psr-0" : { "NomeDoProjeto" : "src/"}
},
"minimum-stability": "dev" ,
"license" : "MIT",
"authors": [
{
"name": "Claudson Oliveira",
"email": "claudsonweb@gmail.com"
}
],
"require": {
"php" : ">=5.3.4",
"silex/silex" : "*",
"respect/relational": "0.4.4",
"twig/twig": "1.6.0",
"facebook/php-sdk" : "*",
"swiftmailer/swiftmailer": ">=4.1.2,<4.2-dev"
}
}
<?php
require __DIR__.'/vendor/autoload.php';
session_start();
define('ENV_DEV',0);
define('ENV_PROD',2);
define('SITE_BASE','http://'.$_SERVER['HTTP_HOST']);
// generals config
if(preg_match('/127.0.0.[0-9]+/',$_SERVER['SERVER_ADDR'])){
error_reporting(E_ALL);
define('ENV',ENV_DEV);
define('APP_ID','');
define('SECRET','');
define('DB_USER','');
define('DB_PASS','');
define('DB_PATH','');
}else{
define('ENV',ENV_PROD);
error_reporting(0);
define('APP_ID','');
define('SECRET','');
define('DB_USER','');
define('DB_PASS','');
define('DB_PATH','');
}
// mailer
define('MAIL_HOST','smtp.gmail.com');
define('MAIL_PORT','465');
define('MAIL_USER','');
define('MAIL_PASS','');
Árvore de diretórios:
- cache/
- public/
- css/
- bootstrap.min.css
- style.css
- js/
- jquery-1.7.2.min.js
- bootstrap.min.js
- templates/
- layout.html
- src/
- uploads/
- composer.json
- config.php
- index.php
<?php
/**
* @author Claudson Oliveira
* @since 2012/09/01
* Padrão de projeto para criar aplicativos
* no facebook usando silex como controlador,
* respect relational pra persistencia do modelo
* e twig pra view
*
*/
require 'config.php';
use Silex\Application;
use Respect\Relational\Mapper;
use Respect\Relational\Sql;
use Respect\Relational\Db;
$face = new Facebook(array(
'appId' => APP_ID,
'secret' => SECRET,
'fileUpload' => true
));
$app = new Application;
$app['http'] = SITE_BASE;
$app['debug'] = (ENV_DEV == ENV);
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__ . '/templates',
'twig.cache' => __DIR__.'/cache',
));
$app->register(new Silex\Provider\SwiftmailerServiceProvider(),array(
'swiftmailer.options' => array(
'host' => MAIL_HOST,
'username' => MAIL_USER,
'password' => MAIL_PASS,
'port' => MAIL_PORT,
'encryption' => 'ssl'
),
));
$app->get('/',function() use ($app){
return $app['twig']->render('layout.html');
});
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment