This is a PHP CRUD following the MVC architectural pattern.
- This application follows the Standard PHP Package Skeleton
- Has a query builder wrapper around PDO
- Has a basic router
- Has a command line tool called
runwhich can be invoked byphp run - Has a basic migration system that creates database tables
- Uses Bootstrap 4
git clone https://github.com/rahamatj/php-mvc-crud.gitcd php-mvc-crud- Create a database called
php_mvc_crud - Rename
config/database.example.phptoconfig/database.php(mv config/database.example.php config/database.php) - Change database configurations in
config/database.phpif necessary. - Edit the
config/app.php. The app won't work if you don't put the url field properly. composer installphp run migrate allphp run seed all- Change directory to the public folder (
cd public) and use php's development server (php -S localhost:8080) - Open up a browser and go to http://localhost:8080
php run invokes the run cli tool.
php run migrate table [table_name]migrates a table which is specified in the migrations list (database/migrations/Migrations.php).php run migrate allmigrates all tables in the migrations list.php run seed table [table_name]seeds a table which is specified in the seeders list (database/seeders/Seeders.php).php run seed allseeds all tables in the seeders list.php run drop table [table_name]drops a table which is specified in the migrations list.php run drop alldrops all tables in the migrations list.
- Create a migration file inside
database/migrationsfolder. - See the
database/migrations/posts_table.phpfor a migration file structure. - See the
src/Database/Table.phpfor the Table class API. This is just experimental, doesn't have the full set of tools which you might find in a typical migration library. - Add the table name and the migration file's class name as
key,valuepair inside the migrations list's (database/migrations/Migrations.php)listfunction.