in Tech

Cruddiy: a no-code Bootstrap CRUD generator

Sometimes you need to give people access to a MySQL database to do some basic tasks. They should be able to Create, Read, Update or Delete database records. And you probably know the user (preferred use-case), but you don’t want to give them access to phpMyAdmin, which is often too difficult (or let alone give them command line access). But you also don’t want to handcode the same PHP CRUD pages again!

Now you can use Cruddiy (CRUD Do It Yourself). To quickly generate 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.

Pages like this are generated without writing a single line of code. Proper titles, pagination, actions and sorting included.

I got tired of programming 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 if you like.

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. Of course there are many PHP Crud generators around, but they are not libre or built on top other larger frameworks or lacked something else, that I was looking for. So I first and foremost built Cruddiy for myself.

Goals and characteristics

  • Simple
    • No dependencies, just pure PHP (and Bootstrap from CDN).
    • Written in PHP and output in PHP. So when the generator runs correctly, your generated app will run correctly.
  • Clean
    • Just generate what’s needed, nothing else.
  • Small
    • If it wasn’t obvious from the above, the app it generates should be small. Kilobytes not megabytes.
  • Portable
    • Cruddiy generates everything in one single /app folder. You can move this folder anywhere. You don’t need Cruddiy after generating what you need.
  • Bootstrap
    • Bootstrap looks clean and is relatively simple and small. I use Bootstrap 3 because I like/know it better than 4.


Why PHP?

  • 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. It stamps out code based on templates. And if PHP is anything it is in fact by default a template engine itself. So it’s a pretty good language for this kind of thing.

Cruddiy does follow not the MVC paradigm!

Yes, looks elsewhere if you need this. This is not a framework.

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 (all fields are required and it doesn’t check field types: integers vs dates etc.). 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!

Next features?

I might add these things:

  • Darkmode
  • Bootstrap 4 theme
  • Export to CSV or XLS (users probably want this more often than not)
  • Rearrange column order
  • Search records (at the top of the page)
  • User registration (simple table with username and password: .htaccess works for now)
  • 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
Cruddiy in action.

Also published on Medium.

Write a Comment