A skeleton for creating applications with CakePHP 3.x.
The framework source code can be found here: cakephp/cakephp.
- Authenticate, Authorize
- Backend ready
- Simple shells => Power tool
- New CRUD bake template
- Send bulk email
- Backup database job
- Store Settings in database
- Improve pages peed: .htaccess, minify html, cdn, cache
- Integrated file manager, tinymce
- Prevent brute force attack
- Remember/Auto login
- Compress whole project to
deploy.tar.gz
file to ship in one click(deploy/compress.sh)
- Provide VERY SIMPLE script to set up nginx (script link)
- Download Composer or update
composer self-update
. - Run
php composer.phar create-project --prefer-dist crabstudio/app [app_name]
.
If Composer is installed globally, run
composer create-project --prefer-dist crabstudio/app [app_name]
Initial new application
- Setup
Datasource
inconfig/app.php
- Run and follow the command:
bin/cake install
- Application ready to use.
Incase you want to wipe and reinstall application
- Run and follow the command:
bin/cake refactory
- Application ready to use.
bin/cake install : install default database
bin/cake refactory : wipe existing database then install factory database
bin/cake users : insert administrator
bin/cake roles : insert 3 default roles [admin, manager, member]
bin/cake settings : insert default settings
bin/cake scheduler : run task, let's create crontab schedule [scroll down to Crontab schedule]
If you want to build an url point to your Controller, build it in the controller and set to the view
// Router
$routes->connect('/verify/:token/:email', [
'controller' => 'Coupons',
'action' => 'verify'
], [
'token' => '[a-z0-9]+',
'email' => '^[A-Za-z0-9._%+-]+@([A-Za-z0-9-]+\.)+([A-Za-z0-9]{2,4}|museum)$',
'pass' => [
'token',
'email'
]
]);
// Build url
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
TableRegistry::get('EmailQueue')
->enqueue(
$emailAddress,
[
'user' => 'Anh Tuan',
'variable_url' => Router::url([
'controller' => 'Coupons',
'action' => 'verify',
$tokenString,
$emailAddress,
'_full' => true
])
], [
'subject' => __('Issue the coupon'),
'template' => 'Coupon/issue',
'format' => 'html',
'layout' => 'default'
]);
// Email view (src/Template/Email/html/Coupon/issue.ctp)
<?= __('Hi {0},', $user)?>
<?= $this->Html->link(__('Verify'), $url)?>
You can use bake to generate CRUD code, then you're ready to use.
bin/cake bake all Posts --prefix admin
Edit src/Template/Element/Admin/navbar_side.ctp
to add more menu
This skeleton use Flat Admin v2 as new bake template
You just do bake code, you're good to go.
Open crontab crontab -e
then add cronjob:
*/5 * * * * cd /path/to/app && bin/cake Scheduler
Go to deploy
folder then double click on compress.sh
I recommend you to use nginx server.
Use this simple script to set up optimized nginx on ubuntu in 4 simple steps.