Here is what I'm working on and thinking about in my spare time!
What I have:
- I've done a personnel database that includes an object-oriented class file for automatically assembling ID badges in sheets of 12. Those sheets can then be cut apart and run through a laminator. Here is the class file and a sample of how to use it. This same project also has a shift scheduling system, and a full HR database.
- My website is run via a home-grown PHP page manager, where I use a page template and seperate include files for actual content.
- I have a PHP class file that programmatically creates web form elements, which saves having to actually type out the form code every time. It's not an object class because, at the time, coding it that way wasn't worth the time.
I like the way PHP handles arrays, especially associative arrays, much better than the way Javascript does. So, I figured I would use PHP's foreach functionality to handle doing repetitive coding tasks in Javascript.
Start with a Javascript template. Note the /* phpSomething */ comments. Then, look at the code generator written in PHP.
I use a PHP foreach loop to create the strings, str_replace to insert the code into the Javascript template, and header to have the returned text interpreted as Javascript. The result is clean Javascript code. (One small difference: for the purposes of showing the generated code, here the header says I'm returning "text/plain" instead of "text/javascript".) The biggest advantage to generating Javascript like this is that I can use the template as a form validator for any number of forms, just by changing a single array in the PHP code generator.
In the web page, I just need to do "<script src="jsBuilder.php"></script>" to get the generated code. I've done similar things to dynamically generate CSS blocks, and a similar technique using str_replace is most of the engine that runs this website.
What I'm thinking about:
- A web-based EMS protocol database that can show individual protocols online and automatically turn out nicely formatted files suitable for printing. Just take a programatically-generated PDF file to your local printer.
- A better production scheduler for the entertainment industry. What I've seen suggests this is a big and complex topic, so it will be slow.
- Creating a PHP class file that runs a flat-file database. Just because I can...
- Writing a PHP class file which allows adding to, updating, and searching a specific database, and then exposing that class file as a web service with appropriate security protections.
Watch this space! There's more to come, including links to more of these projects.