Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_DRIVER = pdo_mysql
DB_NAME = DATABASE_NAME
DB_HOST = 127.0.0.1
DB_USER = DATABASE_USER
DB_PASSWORD = DATABASE_PASS
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
composer.lock
.env
28 changes: 12 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,13 @@ This is an example of VirtualHost:
You can customize the url using the .htaccess file, maybe this will help you:
[http://stackoverflow.com/questions/24952846/how-do-i-remove-the-web-from-my-url/24953439#24953439](http://stackoverflow.com/questions/24952846/how-do-i-remove-the-web-from-my-url/24953439#24953439)

Database Configuration
---------------------
Configuration to connect to database is stored inside `.env` file. If the `.env` file is not in available in root of your project directory, you can rename `.env.example` to `.env` and adjust the value there according to your database.

Generate CRUD backend
---------------------

Edit the file /path_to/admingenerator/src/app.php and set your database conection data:

$app->register(new Silex\Provider\DoctrineServiceProvider(), array(
'dbs.options' => array(
'db' => array(
'driver' => 'pdo_mysql',
'dbname' => 'DATABASE_NAME',
'host' => 'localhost',
'user' => 'DATABASE_USER',
'password' => 'DATABASE_PASS',
'charset' => 'utf8',
),
)
));


You need to set the url of the resources folder.

Change this line:
Expand Down Expand Up @@ -104,6 +91,15 @@ The generated code is fully configurable and editable, you just have to edit the

It has generated a folder for each database table.

Serve Using Built-in PHP Server
--------------------
If you want to serve this project using built-in PHP server, run: `composer run serve`. It will serve the project from localhost:8888. To change the port to something other than 8888, you can edit it inside `composer.json`:

```
"serve": [
"php -S localhost:8888 -t web"
]
```

Contributing
------------
Expand Down
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@
"symfony/validator": "2.5.*",
"symfony/config": "2.5.*",
"symfony/translation": "2.5.*",
"symfony/locale": "2.5.*"
"symfony/locale": "2.5.*",
"vlucas/phpdotenv": "^2.4"
},
"minimum-stability": "dev",
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"serve": [
"php -S localhost:8888 -t web"
]
},
"autoload": {
"psr-0": { "": "src/" }
}
}

17 changes: 11 additions & 6 deletions src/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ class queryData {
public $recordsFiltered;
public $data;

function queryData() {
function __construct() {
}
}

use Silex\Application;
use Dotenv\Dotenv;

// fetch config from .env file
$dotenv = new Dotenv(__DIR__.'/..');
$dotenv->load();

$app = new Application();

Expand All @@ -38,11 +43,11 @@ function queryData() {

'dbs.options' => array(
'db' => array(
'driver' => 'pdo_mysql',
'dbname' => 'DATABASE_NAME',
'host' => '127.0.0.1',
'user' => 'DATABASE_USER',
'password' => 'DATABASE_PASS',
'driver' => getenv('DB_DRIVER') ?: 'pdo_mysql',
'dbname' => getenv('DB_NAME') ?: 'my-db',
'host' => getenv('DB_HOST') ?: '127.0.0.1',
'user' => getenv('DB_USER') ?: 'root',
'password' => getenv('DB_PASSWORD') ?: '',
'charset' => 'utf8',
),
)
Expand Down