I started PHP programming around 2002, when there were not that many frameworks around. Over the years, I developed my own PHP framework, which seems to be entirely different from any standard I come across.

I'll try to describe the framework that I created:

Basically it's an engine that builds an entire web-application, by converting template-files into HTML-files. An application typically consists of template-files for each different page in the application and some custom CSS / JS-files for things that are not (yet) in the engine. User-interaction is done with standard PHP-scripts in the framework that can handle all kinds of operations (select, create, update, view, delete, sending e-mails, export as PDF or Excel, etc.). The engine automatically knows which scripts should be used and all variables needed for these scripts to work are sent by Javascript using Ajax, including the operation-type and all needed form values. JSON or an URL to the created PDF or Excel-file is then sent back to the client.

The templates can contain clientside HTML, CSS and Javascript and serverside SQL, but most important are custom xml-tags that are interpreted by PHP and, depending on the attributes, converted into (multiple) HTML-tags, CSS and Javascript-code. There are a lot of different standard PHP-classes for custom tags that can output visual things, like buttons, datagrids, forms, etc. but the tags and attributes are also used for database-stuff, sessions, clientside updates using Ajax/jQuery, producing PDFs, sending e-mails, etc. The engine can use all kinds of libraries, like jQuery UI, Cordova, Bootstrap, PHPExcel, mPDF, etc. and automatically knows which JS and CSS-files to include in the outputted file. It can also cache the HTML, build the application and minify the JS and CSS.

This way I have no specific classes for anything that is in the application or database (e.g. Accounts or Invoices). When my data-model changes I only have to update the templates, and no PHP-code at all.

Every framework I'm trying out (e.g. Phalcon, CakePHP and Laravel) seems to require to define the business-logic, data-model and all interactions in specific PHP-classes (e.g. Account or Invoice). So when a field is added to a database-table, you need to add a property to its corresponding class. But of course also change the view-templates and interaction-controllers. And for every table in the database different model and controller files are needed. I think this is quite complex and time consuming, compared to my solution (some of my applications use 100+ different database tables).

The downside of my approach is that maintaining the standard-classes in the framework takes a lot of work. Especially because in different applications the same classes need to be able to behave a bit different, so every class has lots of properties to control all this. This way the engine has become very powerful, but also quite slow, complex and difficult to maintain. I realize that my solution doesn't really separate the code and design, but since I build mostly database web-applications, this is not really necessary for me. The way things look can be manipulated enough using some custom CSS.

So, where to go from here now? I really love my framework, but would like to comply more with web-standards to be able to hire external developers a bit easier. But since my framework is quite different from anything else, I have no idea which framework to choose.

My questions are :

  • What do you think of my 'web-application-engine' that mostly uses templates only? Does anybody else do this?
  • Which existing framework could be used to complement my own framework, rather than entirely change the way I work now?
  • 1
    Your first question is essentially an opinion poll or discussion, and your second question is a resource request – user22815 Dec 14 '15 at 0:21
  • On the point of complementing your own framework, I'd use Laravel. It's an extremely decoupled framework that you can use parts of. My best advice though? Stop developing a framework by yourself. Even if you lose your head-start when developing, there's nothing stopping you from creating some template projects and reusing them, regardless of the framework you end up using. – Alternatex Dec 14 '15 at 9:04
  • 1
    It seem like you have developed a crud generator. All of the frameworks you mentioned also have plugins for crud generation. So maybe just look a little bit deeper. – Cerad Dec 14 '15 at 13:12
  • No I created an entire webpage generator that does CRUD using default scripts with all necessary parameters in a POST submit instead of having a different class or script for each operation or table. I admit, it's a bit exotic. – Dylan Dec 14 '15 at 14:25

PHP is a simple language by nature. It has many useful libraries but no built-in web framework unlike others such as C# and ASP.NET framework.

Therefore you need to use frameworks:

  1. If you decide to write your own framework you will need strong understanding of design and structural patterns. If not it will be a challenge to maintain or modify the code.
  2. If you use a known framework like one of the ones you have cited, the framework will be already written and well tested by tons of developers.

Remember PHP was itself written by its author to help him solve his own problems. This is how most frameworks got started. If your framework solves a problem that other frameworks can't then it might be worth it, you will also learn from doing it, otherwise you are reinventing the wheel.

Personally, when I first started programming I was anti-framework, writing my own helper classes. With the customers' ever changing needs, my elegant code eventually turned into nasty spaghetti code. I remember one time my boss asked me to remove a check Box from a page and when I removed it, it caused my half-baked web framework to crash during a demo. I learned from this that the MVC pattern would have avoided this issue. I since then use well known and tested frameworks to save time spent by other developers that I cannot afford to waste.

From your post it sounds like you are already facing issues with writing your own framework, that is the trade off, it seems to make things easy at first but then it's hard to modify. On the other hand other frameworks would seem like an overhead but in the long run it makes your application tighter.

You can choose any of these popular frameworks to achieve your task. The advantage of using Models and properties is that your views will be strongly typed which is much safer.

Not the answer you're looking for? Browse other questions tagged or ask your own question.