LEVEL: PHP Advanced / Symfony2 Novice
This blog will have 3 features
- Users (add, delete, edit, login)
- Posts (add, delete, edit)
- Replies (add, delete, edit)
You need to have PHP 5 or 7 and Mysql Server running
Install Symfony
$ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/bin/local/symfony
Create App
php bin/console new blog 3.1
Create Bundle
php bin/console generate:bundle
- call it BlogBundle
Edit databaseconfiguration
open parameters.yml in config folder and edit databaseaccess
Create a database
php bin/console doctrine:database create
- call it blog
open a mysql client (fy mysql-workbench)
create needed tables
CREATE TABLE `replies` (
`id` int(11) NOT NULL,
`userid` int(11) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`content` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`firstname` varchar(255) DEFAULT NULL,
`lastame` varchar(255) DEFAULT NULL,
`username` varchar(50) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`isDeleted` tinyint(4) DEFAULT NULL, `isActive` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `blog`.`posts` (
`id` INT NOT NULL COMMENT '',
`userid` INT NULL COMMENT '',
`title` VARCHAR(255) NULL COMMENT '',
`content` TEXT NULL COMMENT '',
`isDeleted` TINYINT NULL COMMENT '', `isActive` TINYINT NULL COMMENT '',
PRIMARY KEY (`id`) COMMENT '');
create entities from database:
php bin/console doctrine:mapping:import --force BlogBundle xml
php bin/console doctrine:mapping:convert annotation ./src
php bin/console doctrine:generate:entities BlogBundle
Install twitter boodstrap crud bundle
https://github.com/petkopara/TritonCrudBundlegenerate crud controllers with twitter bootstrap look and feelphp bin/console triton:generate:crud