Sometimes you need to give people access to a MySQL database to do basic tasks. They should be able to Create, Read, Update or Delete database records. And you probably know the user, but you don’t want to give them access to phpMyAdmin, which is often too difficult (or let alone give them command line access). And you also don’t want to handcode the same PHP CRUD pages again!
Now you can use Cruddiy (CRUD Do It Yourself). To generate beautiful and clean CRUD pages with zero code.
You’ve probably seen pages like this a thousand times before. And now you can make them with a few clicks.
I got tired of writing the same pages over and over again for some simple database actions. So in classic yakshaving fashion I decided to automate this, and built a generator that generates PHP CRUD pages.
Cruddiy is a no-code PHP generator that will generate PHP Bootstrap CRUD pages for your MySQL tables.
Cruddiy output is an /app folder with everything you need. You can move this folder anywhere and delete Cruddiy.
Most MVC frameworks (e.g. Symfony, Django, Yii2) are also able to generate CRUD pages for you. I have used all of these. But more often than not you end up with 80MB of code (no joke) with all kinds of dependencies that you need to deploy and maintain for just a couple of PHP pages! This rubs me the wrong way. Also there seem to be PHP Crud generators around, but they are not libre.
Goals and characteristics
- No dependencies, just pure PHP (and Bootstrap from CDN).
- Written in PHP, output in PHP. So when the generator runs correctly, your generated app will run correctly.
- Just generate what’s needed, nothing else.
- If it wasn’t obvious from the above, the app it generates should be small.
- Cruddiy generates everything in a /app folder. You don’t need Cruddiy after generation what you need. And you can move this folder anywhere.
- Looks clean and is relatively simple and small. I use Bootstrap 3 because I like/know it better than 4.
- Love it or hate it: but PHP is ubiquitous. You can download Cruddiy on most webservers and you’re good to go. wget the zip -> unpack -> surf to the folder in your browser and follow instructions.
- Cruddiy is of course a sort of templating engine. And if PHP is anything it is in fact by default a template engine itself!
Cruddiy does follow not the MVC paradigm!
Yes, looks elsewhere if you need this. These are database table views.
Your code is full of dirty hacks
I might do quite a bit of array mangling and string replacement, but the PHP pages Cruddiy generates are as clean as they come. And when you’re done generating pages, you can just delete Cruddiy. It completely builds a self-contained portable app that will run on almost any webserver with PHP (i.e. most).
Your generated code is incomplete
At the moment what’s lacking is error value checking on database inserts/updates. These will throw general errors or don’t do anything at all. I will probably improve this, but for most use-cases (see above) this should not be a problem. The generated code does use prepared statements and should not be vulnerable to SQLi. But hey, drop me a line if you find something!
I might add these things:
- Bootstrap 4 theme
- Export to CSV or XLS (users probably want this more often than not)
- Rearrange column order (but only if can be done simply)
- Search records (at the top of the page)
- User registration (simple table with username and password)
- Define table relations (use for cascading deletes etc.)
- More specific field types (ENUM = drop-down list etc.)
- More and better input validation
- Catch more database errors
Originally published at Jan van den Berg.