Do you like working with PHP Frameworks?

Fair enough. I will refrain from calling people idiots in the future. @John_Betong you’re not an idiot. I apologize.

2 Likes

[off-topic]

Please supply a link to consolidate your statement.

[/off-topic]

1 Like

Ci is maintained but it is not maintained very well. It was handed off to an educational facility to maintain from EllisLabs. I really think CI a decade ago was a great framework but if you don’t advance with the technology you will become obsolete. CI is one of those frameworks that has not had maintainers who are willing to recognize the changing landscape and adapt their framework to compete technologically with the advances of the last decade. I do actually think CI is great basic MVC framework but frameworks have evolved way past that. One of things that makes CI great to beginners and easy to understand is what makes it terrible for long term development efforts. That is the maintainers inability or laziness to recognize libraries that do things very well like sending emails and integrate it into their platform. Instead CI chooses to have a bunch of god classes/libs/helpers that do things that would be much better off delegated to well known libs managed by a dependency management system like composer. Modern application architecture provides solutions to common problems that leverage well known, documented, and robust solutions to common problems like sending emails. They don’t enforce a gigantic, custom god class to handle these tasks, Good, modern frameworks provide ways to easily swap out common functionality yet provide a well known community default. CI does not do that. I know people will dump on Laravel all day but one thing Laravel does very well is provide a flexible interface to replace default providers for everything from email handlers to replacing eloquent (Active Record) with a full fledge ORM like doctrine. CI is just so selfish in the way that it enforces usage of custom libs/helpers for things that are much better delegated to other packages that have much better documentation, community support, and advanced features. With that said I will reiterate on the conversations that happen between those devs when they chose not to adapt to the new landscape. If you know anything about programming some of the reasons why they are not implementing modern practices is just utterly ridiculous. The reasons why they don’t use an abstracted email interface to make it possible to swap out an email provider, the reason why they stick to AR over an ORM, the reason why they don’t have routing configs, the reason why they don’t use DI or a DIC (dependency injection container), the reason why they provide no integrated solitions ot a master layout that includes asset management. Its all just really a bunch of excuses and a complete joke. CI was once a great frameworkI will not argue that but now absolutely not. I will apologize for calling people idiots but I will never apologize for saying that CI is a pile crap to be avoided in this day and time. Despite all this CI has a huge following. I mean I understand why I just wish that some devs would step outside their comfort zone and embrace more modern methodologies. If its not Laravel there are plenty more ways to do things they all involve embracing what the community has created to solve a problem rather than reinventing the wheel and that all starts with learning to use composer in php and becoming familiar with all the great, modern packages available.

1 Like

Many thanks for the verbose reply.

I appreciate there are many better PHP Frameworks, more advanced and use up the latest standards.

CodeIgniter more than satisfies my needs and I will stick with it because it robust and has served me very well. I look forward to the imminent CodeIgniter4 release and also the criticism which will no doubt follow rapidly.

1 Like

I think most if not all frameworks have a “too” something or other. Too bloated, too thin, too many dependencies, too outdated, too steep a learning curve, too difficult to configure, too simple, too rigid, too loose. etc. etc. etc.

IMHO unless you are working with a team where you have no choice, finding something you like using that meets your needs is a good thing to have found. They’re only a tool after all and not everyone will prefer the same for their work.

6 Likes

There are often good reasons to roll your own. I’ve found other systems are either too generic (though do most of what you want but the time you save in the short term you lose later on trying to bend it to do the things it won’t do) or add too much bloat/are too slow.

Selfish or stupid are not words I’d choose to call someone who successfully creates their own framework when there is a need to.

That said, I believe you should listen to the client requirements and then make a call as to what to use. I’ve never understood these people who use WordPress, Laravel or whatever else for the same project regardless.

My approach for what I would call custom work is that I have my own opinionated CMS framework that is extremely performant, even on shared server. The assumption is that I coded it all myself. I didn’t. I use libraries on a modular basis. Examples are:

  • SwiftMailer for emails
  • Intervention for image manipulation
  • League Container for DIC
  • Dom PDF for PDF generation

I like this approach because my bets are hedged. If SwiftMailer is discontinued or there is a bug that no one wants to fix I can simply swap it out for PHPMailer. Since my framework uses wrappers for any libraries it wouldn’t be a huge job. If I had used an entire framework I’m committed to the whole thing.

Having said that, the likes of Laravel aren’t going anywhere soon but I personally like this approach as I am not reinventing the wheel but I get to work with a framework that functions as I would expect it to.

5 Likes

That’s the best way.

I also like that approach of using separate modules rather than using a complete jumbo framework.

But there are many in this world who don’t like this approach. They will clearly say that we need a Laravel expert to work on our Laravel project.

1 Like

They will clearly say that we need a Laravel expert to work on our Laravel project.

There is a real problem with clients presupposing the system they should we using. “We want to use WordPress” is quite common. But really, it’s down to us to find the best system for our clients. I don’t use WordPress at all anymore, even for blogs, so I tend to avoid the “We want to use WordPress” jobs like the plague. It tends to be because the CEO’s nephew knows how to install themes therefore it’s the best choice and he/she will take over the “development” once it’s live.

The fact of the matter is, framework or not, there are pros and cons to each option.

For brochureware sites, for example, I find Processwire to be second-to-none when it comes to managing content in a WordPress ACF kind of way. But it has nothing when it comes to eCommerce. Frameworks like Laravel give you the tools to make a CMS but don’t actually come with a CMS (though there are of course CMSs built on Laravel).

I’ve thought about this a lot over the years and always come back to the same approach: evaluate the needs, shortlist the options, discuss with the client and then go with one. Establish a good relationship and the issue is not so much the platform you end up using as much as we need to avoid the scenario where I stop working on the site and someone else starts on it as, regardless of platform, this causes headaches.

I’ve been doing this for a long time and can count on one hand the amount of clients I’ve lost — and they’ve never been for sinister reasons. I am always transparent about the pros and cons and in all that time not one single client has ever expressed any negativity whatsoever, not one iota, about me using my own custom solution. They tend to either like the idea or are indifferent.

3 Likes

There is one more thing related to PHP frameworks - code generation. Frameworks are meant to speed up coding by getting rid of the need to do common repetitive tasks but still there is a lot to do on our own. I’ve heard an opinion that if a programmer uses tools to generate source code automatically then this indicates that something is not right probably because we should be using reusable components instead. I’m not so sure about this and was wondering what you think about code generation and whether you use some kind of code generation in frameworks.

This topic came up in my mind now because in my old framework I had a code generation tool for CRUD operations. The framework components were a bit too tightly coupled to my current liking, they were using ActiveRecord pattern ORM and quite a lot of static classes but for simple systems it worked pretty well. Recently, I was given a task of updating a web site I made some 5 years ago and I needed to add a News component - a simple database table with entries - title, content, date and some other fields. After creating the table in mysql I fired up my generator, which detected all the fields from the database, I added labels, tweaked a few properties and within minutes I had the whole CRUD code for my administration panel ready and working - news listing with pagination, sorting and search, entry adding/editing with form validation, entry hiding/showing and deleting. I thought this was very convenient and fast. I had all necessary files ready (PHP and templates) that I copied to the destination folders and they worked right away. I’m missing now this kind of productivity tool and wished I had something like that for my current systems - but a bit more framework independent.

What’s your opinion on this?

1 Like

One of the great things about Laravel is how it uses a bunch of independent libraries. That is in essence what makes it different than legacy frameworks like CodeIgniter.

1 Like

Better then the single php developer who developed some half ass framework with no documentation or community.

I was having a conversation with a colleague the other day where we concluded that well-designed frameworks behave more like a collection of libraries rather than containing the application and dictating how the code is written.

That conversation stemmed from this picture I found in an article comparing frameworks to libraries:

I would agree that is definitely the way forward for rapid development and in teams, and it does provide a maintenance advantage that may increase your application life-span.

I also really agree with this:

Frameworks are one size fits all, and if you have the expertise you may not need a sledge-hammer to crack a nut. If the time and money allows and those are the business needs, nothing can beat tailored expert work to solve a very particular problem. That’s not to say build it all yourself, but a bit of research and solution architecture may prove enlightening to decide which bits to build yourself and which other bits to use from elsewhere.

In my opinion and in the age of tools and package managers, I surprisingly see too little thought and research given to solution architecture and a lot of dogmatic overload of tooling just for the sake of it.

Hey @Lemon_Juice what does exactly code generation mean? Is this like an UI or configuration through which you can set-up a full-fledged admin section with a database table and custom fields to perform CRUD operations, and views with filters of that data, plus automatically generated templates and config files?
I’m not very familiar with the term and after searching for a bit in Google I ended up more confused. If you cared to explain I would be grateful.

2 Likes

Yes, that’s what I mean - generating files for a CRUD admin section for a table. A tool like this may look like a form where you provide basic information for each table column and then all files for CRUD are automatically generated so basically for simple tables you can create admin panels without any coding. Of course, the generated code becomes part your application so you can modify and add stuff to it later on as you please so you are not limited to how and what the generator produced.

1 Like

Well I think any good CMS framework should have simplified enough the process of building the admin sections programmatically so that it can be done relatively easily through a code generator. It’s a good idea to get you up and running a little faster.
Although I think for this to be effective you need a lot of work and proper architecture behind it

1 Like

This is exactly it. And as always it’s about choosing the right tool from the right job. A large framework comes with certain baggage. You need to decide whether the pros outweigh the cons; the same goes for a custom job.

It’s been a while since I tried Laravel but for me it was too opinionated, didn’t like facades (yes, I know you don’t have to use them) and for a relatively simple app on a shared server I wasn’t happy with the execution time or the memory footprint (it may have changed a lot since then, especially with PHP 7). Don’t get me wrong, I think Laravel is really well designed and shows how nice modern PHP can be. Generally though I’d favour a lighter weight frameworks that’s more like a library per that diagram @Andres_Vaquero posted.

I actually really liked CI when I first tried it out but didn’t pursue it but even back than Phil Sturgeon didn’t seem to have his heart in it anymore.

Yes, and really anything that uses some kind of autoloader. Composer is really wonderful when you think about it. The ease with which you can include libraries is extremely useful.

1 Like

Are you referring to generating PHP code? If so, can it not br abstracted so you pass data to reusable objects? Isn’t maintainability poor with this approach because if something was updated you would have to manually update all previously generated files? To me, that’s like, for example, changing the WordPress core and then being stuck with either updating it every time the core is updated or never updating it.

Yes and more - generating controllers, models, routes and templates for all CRUD operations.

Probably yes, and that’s the main question. But in order to use reusable objects I’d need to have a sort of CMS library to use for all my tables.

A few years ago I used this kind of code generation often and my experience was the maintainability was far from poor - quite the opposite. The role of the code generator is not that you have to use it every time something is updated - the code becomes your source code and if something changes you simply update it by hand - just like the rest of your source code that you wrote by hand. Of course, if you want to change the core of your CMS and do some heavy refactoring then you would have to generate everything from scratch or manually change the generated code - but I’ve found that admin panels usually don’t need that kind of refactoring, once it works it’s good for the client.

The idea behind the code generator was to leave full control over the code. If I used a CMS library for CRUD then it is easier to upgrade the whole system but I am allowed to only use the features of the library - if I need something unusual then I need to add the feature the library. And with time some CRUD operations become less CRUD as the system evolves and change to quite complex operations - at that time those reusable CRUD objects would become more hindrance than help.

Quite often I started an admin panel using the generated code and then worked manually on adding additional custom features. The initial boost in productivity was quite huge. And then if necessary, it was easy to add any kind of feature without worrying if a CMS would allow that - because I remained in full control of the code. Sometimes, I even used the generator to add features to my already custom code - then I would generate new code and copy only the portions that were necessary - still could be faster than doing it by hand.

I know that a CMS library is also a valid approach. But then my admin panel is dependent on the library - even if it’s written by me this is another layer added to my application code. Whereas code generation is like quickly producing source code that is independent and easy to modify at a later time. Each has their pros and cons but I’ve found that indeed code generation is a much less popular idea.

I can’t say I’ve ever entertained that approach but yes, they have pros and cons.

I am firmly down the CMS library route and it is driven almost entirely by config (JSON and MySQL).

  • Build a form
  • Map the form to the database
  • In the backend the CMS library does all the CRUD including browsing and search records
  • Front end is a nice Vue.js single page application

Unless you need to do anything out of the ordinary, which is rare, you don’t actually need to write any PHP. If you do, it uses an hook system that is completely abstracted from the CMS library. As I add more content types I simply update the core and they become available. I would find that hard with the code generation method.

Yeah i like it. Altough i am new to the PHP programming and have not a good command over it.

It’s interesting that so much different approaches work for both of us and I suspect we both find it easier to work with what we have experienced.

Anyway, do you make your own CMS library or use an available package - and if so, which one?