in Tech

Cruddiy: a no-code Bootstrap CRUD generator

Here’s a situation. Let’s say you have a MySQL database, where the user should be able to do some standard database actions, like Create, Read, Update or Delete database records. Nothing fancy.
And, you probably know this — usually — non-technical user, so you don’t want to give them access to phpMyAdmin, which is often too difficult. Or let alone give them command line access! So you need some simple database forms built on top of your MySQL database, but you also don’t want to handcode the same PHP CRUD pages again!

Now you can use Cruddiy (CRUD Do It Yourself) and quickly generate clean CRUD pages with zero coding.

You’ve probably seen pages like this a thousand times before. And if you have a MySQL database you can now make them yourself with just a few clicks.

Pages like these are generated without writing a single line of code. With proper titles, pagination, actions (view/edit/delete) and sorting included.

Above is the old Bootstrap 3 look. This is the new Bootstrap 4 look:

20200409-cruddiy-app-index.png (1157×729)
Cruddiy with Bootstrap 4 and search

I got tired of programming the same pages over and over again for some simple database forms. 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 which includes everything you need. You can rename and move this folder anywhere you want and even delete Cruddiy when you’re done. Because Cruddiy is only used to generate the /app folder. And the /app folder is what your user will use.

Why Cruddiy? tool xyz does the same thing!

Most MVC frameworks (e.g. Symfony, Django or Yii2) are also able to generate CRUD pages for you. I have used all of these. But usually you end up with at least 80 Megabytes 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.
And of course there are many other PHP Crud generators around, but they are not libre or, more often than not, built on top other larger frameworks: so they have the same problem. Or they simply lack something else. So when I couldn’t find anyone that fit my needs I decided to make Cruddiy.

Cruddiy goals and characteristics

  • Simple
    • No dependencies, just pure PHP (and Bootstrap 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 and know it a bit better than 4.

FAQ

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 -> check webserver permissions (chmod) -> surf to the unpacked 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 only works with MySQL (for now): and MySQL and PHP are of course two peas in a pod.

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

Sure, the generator does quite a bit of array mangling and dirty 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, please drop me a line if you find something!

Next features?

I might add these things:

  • Darkmode
  • Bootstrap 4 theme ✔️ Fixed per 20200803
  • Export to CSV or XLS (users probably want this more often than not)
  • Rearrange column order
  • Search records (at the top of the page) ✔️ Fixed per 20200722
  • 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 BOOLEAN = checkbox etc.)
  • More and better input validation
  • Catch more database errors
Cruddiy in action.

Also published on Medium.

Write a Comment

Comment

  1. hello, I’m still new to web programming. I have not mastered the use of php framework correctly. Every time I want to make a CRUD application I have to code every function needed. this also happens when updating / adding columns to the table. CRUDDY is very simple and helpful. this makes me excited again. thank you