Skip to content

Commit 4a597df

Browse files
committedApr 7, 2015
initial commit
0 parents  commit 4a597df

12 files changed

+203
-0
lines changed
 

‎Berksfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
site :opscode
2+
3+
cookbook 'apt'
4+
cookbook 'hf-lamp', git: 'https://github.com/hellofuture-cookbooks/hf-lamp.git', tag: '0.1.18'
5+
cookbook 'phpunit', '1.0.2'

‎Vagrantfile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
Vagrant.configure("2") do |config|
5+
config.berkshelf.enabled = true
6+
config.omnibus.chef_version = :latest
7+
8+
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", mount_options: ["dmode=777","fmode=666"]
9+
10+
config.vm.provider "virtualbox" do |v|
11+
v.customize ["modifyvm", :id, "--memory", "2048"]
12+
end
13+
14+
config.vm.box = "forms"
15+
config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box"
16+
config.vm.network :forwarded_port, guest: 80, host: 9079
17+
config.vm.provision :chef_solo do |chef|
18+
chef.cookbooks_path = ".provision"
19+
chef.add_recipe "apt"
20+
chef.add_recipe "hf-lamp::web"
21+
chef.add_recipe "hf-lamp::mysql_server"
22+
chef.add_recipe 'phpunit'
23+
chef.json = { 'mysql' => {'server_debian_password' => '739e8971e306f8dae3b27582bab8bc82',
24+
'server_root_password' => '739e8971e306f8dae3b27582bab8bc82',
25+
'server_repl_password' => '739e8971e306f8dae3b27582bab8bc82'},
26+
'hf-lamp' => { 'docroot-dir' => '/vagrant',
27+
'sites' => [{'host' => 'localhost',
28+
'docroot' => 'www',
29+
'single-vhost' => true,
30+
'manage_db' => true,
31+
'db' => {'user' => 'forms',
32+
'name' => 'forms',
33+
'password' => 'forms'}}]}}
34+
35+
end
36+
end
37+

‎composer.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name":"hellofuture/customforms",
3+
"type":"cms",
4+
"description":"Custom forms for your php website",
5+
"license":"MIT",
6+
"authors":[
7+
{
8+
"name":"hellofuture"
9+
}
10+
],
11+
"require":{
12+
"php":">=5.3.0",
13+
"slim/slim":"2.*",
14+
"slim/views":"0.1.*",
15+
"illuminate/database":"*",
16+
"twig/twig":"1.*"
17+
},
18+
"autoload":{
19+
"psr-0":{
20+
"": ""
21+
}
22+
}
23+
}

‎lib/Config.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace lib;
4+
5+
// Configuration Class
6+
class Config {
7+
static $confArray;
8+
9+
public static function read($name) {
10+
return self::$confArray[$name];
11+
}
12+
13+
public static function write($name, $value) {
14+
self::$confArray[$name] = $value;
15+
}
16+
}

‎lib/Core.php

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace lib;
4+
5+
use lib\Config;
6+
use PDO;
7+
8+
class Core {
9+
public $dbh; // handle of the db connexion
10+
private static $instance;
11+
12+
private function __construct() {
13+
// building data source name from config
14+
$dsn = 'mysql:host=' . Config::read('db.host') .
15+
';dbname=' . Config::read('db.basename') .
16+
';port=' . Config::read('db.port') .
17+
';connect_timeout=15';
18+
// getting DB user from config
19+
$user = Config::read('db.user');
20+
// getting DB password from config
21+
$password = Config::read('db.password');
22+
23+
$this->dbh = new PDO($dsn, $user, $password);
24+
}
25+
26+
public static function getInstance() {
27+
if (!isset(self::$instance))
28+
{
29+
$object = __CLASS__;
30+
self::$instance = new $object;
31+
}
32+
return self::$instance;
33+
}
34+
35+
// others global functions
36+
}

‎models/Form.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace models;
4+
use lib\Core;
5+
6+
class Form extends \Illuminate\Database\Eloquent\Model {
7+
8+
9+
}

‎routers/index.router.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
// GET index route
3+
$app->get('/', function () use ($app) {
4+
$app->redirect('/listing');
5+
});

‎routers/listing.router.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
// GET index route
3+
$app->get('/listing', function () use ($app) {
4+
5+
$c = array();
6+
7+
$form = new models\Form();
8+
9+
$c['forms'] = array();
10+
11+
$app->render('pages/listing.html', $c);
12+
13+
});

‎templates/layout/layout.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
3+
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
4+
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
5+
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
6+
<head>
7+
<meta charset="utf-8">
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
9+
<title>{{ title }}</title>
10+
<meta name="description" content="">
11+
<meta name="viewport" content="width=device-width, initial-scale=1">
12+
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
13+
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
14+
</head>
15+
<body>
16+
<div class="container">
17+
{% block content %}{% endblock %}
18+
</div>
19+
</body>
20+
</html>

‎templates/pages/listing.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% extends "layout/layout.html" %}
2+
{% block content %}
3+
<h1>Listing</h1>
4+
<div class="row">
5+
6+
<div class="col-lg-12">
7+
{% for f in forms %}
8+
{{ f }}
9+
{% endfor %}
10+
</div>
11+
12+
</div>
13+
{% endblock %}

‎www/.htaccess

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RewriteEngine On
2+
RewriteCond %{REQUEST_FILENAME} !-f
3+
RewriteRule ^ index.php [QSA,L]

‎www/index.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
require '../vendor/autoload.php';
4+
require '../config.php';
5+
6+
// Setup custom Twig view
7+
8+
$twigView = new \Slim\Views\Twig();
9+
10+
$app = new \Slim\Slim(array(
11+
'debug' => true,
12+
'view' => $twigView,
13+
'templates.path' => '../templates/',
14+
));
15+
16+
// Automatically load router files
17+
$routers = glob('../routers/*.router.php');
18+
19+
foreach ($routers as $router) {
20+
require $router;
21+
}
22+
23+
$app->run();

0 commit comments

Comments
 (0)
Please sign in to comment.