Laravel vs CakePHP?


#1

So, this might come to some as a troll or maybe as a “don’t discuss this here, we only do CakePHP” or “Do not mention other frameworks here” topic, but it’s actually quite a serious question for me as I want to clear up something for myself (and probably for some others that start out with frameworks as well):

You see, every time I mention that I use CakePHP to somebody, they say: “You shouldn’t use that for anything but creating a quick prototype” or “If you want to create something that remains maintainable go with Laravel”.
Basically, they say Laravel is superior to CakePHP.
Since CakePHP is the first PHP Framework I actually was able to use (it learned me the basics of MVC), this is what I stuck with.
But I wanted to know from somebody who has worked with CakePHP (and Laravel) before, what makes you stick with CakePHP?
Or is what the others say true and should I use CakePHP more for prototyping rather than creating stuff for the long term?

This is something that has been on my mind for a while, but I never really had the courage to ask it on a forum that is dedicated to one of the frameworks…


#2

I have used laravel since ver 4.2, and I am not jut saying I know laravel pretty well, I am number 20 on the leader board.

So laravel vs cakephp is the question.

I think they are both php frameworks and I like any of these.

  • Cakephp
  • Laravel
  • Yii2

I find laravel easier to customize. Taylor made it very flexible.

Cakephp is good except for one thing, they made the querybuilder return nothing if a zero is stored in a tinyint. Laravel returns

What is actually stored.

Yii2 is similar, but a little harder to “turn off things you don’t use”.

And even in laravel if a query gets complex, or I have to start using the raw expression, I instead of using eloquent use the native pdo instance getPdo().

I even did a guide on laracast https://laracasts.com/discuss/channels/guides/getpdo-usage

So even if cake or laravel is missing something you need, you as a developer can either program it in or find a package.

Bottom line cakephp, laravel, yii2, don’t matter. All php frameworks, all kind of similar.

Also you stated

This is something that has been on my mind for a while, but I never really had the courage to ask it on a forum that is dedicated to one of the frameworks…

For one long term site I had, that did not need special things like:

  • scheduling
  • events
  • etc

It was mainly crud operations. I heavily modified an older framework SMVC, made it php 7.1 compatible and used it.

You will find that large enterprise such as

  • Fedex
  • JB Hunt
  • CH Robinson
  • Landstar
  • Etc

Aren’t using any “off the shelf” framework, they have highly customized specialized code.
Of course most large enterprise use java technology. I once worked at a medium sized trucking co and I used servlets, ejb’s, and jsp. I was looking at hibernate, but never used it.

But php is fine for up to a larger medium sized site. Too big look into load balancing.

By the way, hibernate and doctrine orm are similar, real entity mappers.

Cake, laravel, yii2 orm’s just active record. Fine for smaller databases, but not so great for larger.

As an example, say you eager loaded relations, where you had a foreach in a foreach.

Ok great, my orm is great, My little post with comments is so cute.

But

Now do one where the inner foreach has tens of thousands of records.

Enough said on that.

But it all gets back to just retrieving the data needed. Normally a huge resultset like that is for monthly A/R and A/P reports. Complex reports is another ball game.


#3

hmmm interesting.

So except for that querybuilder thing, there is not that much different in terms of core functionality.
Interesting to hear this, especially from somebody who used Laravel a lot…
Because all I hear from Laravel users is that CakePHP is inferior to Laravel when it goes beyond prototyping…


#4

If you dig around in the vendor folder in laravel you will see normal regular ol PHP and PDO are used basically a framework is a series of short cuts for the framework user.

A bunch of work is done by the framework writer and maintainers to make things easier. But like I said when all is said and done basically PHP and PDO. Of course some other packages also like mailing, events, ect.

In my custom frame work I do my own authorization and csrf-protection and things like that.

Even if you use a framework, certain things you should practice without a framework just to learn.


#5

Yea, I’ve been doing PHP for about 5 years now (god that sounds wrong), and learned a lot about the security perspective by means of the hard way (people finding exploits and patching me it up).

But yea, if there isn’t anything that really makes Laravel worth the switch, then I know enough :slight_smile:
Thanks!


#6

My opinion.
You should ask another:

  • What can’t I do with CakePHP, for example?
  • How many time have I spent with CakePHP compared with Laravel for the same task?

I think CakePHP can do the same that Laravel and much more faster in 90% situation.

BUT!
CakePHP has the largest problem with information. Therefore Laravel growths.
If you have some question with Laravel you type in Google “Laravel bla bla bla …” and you will get large number of various decision in any sites.

In CakePHP you can find some decision for old version. But there is normal cookbook for 90% tasks. Of course in official site you will find something naming with “cookbook” but it’s very basically or professional. There are many words for explaining simple topics and you need to guess much “how to…”:

  • How to create different your own filters and their groups
  • How to create shopping cart
  • How to realize messages between your users
  • How to create payment system in your site
  • How to realize ajax in your project
    And much more.

As for me this is the main problem. First you try Cake and see how it’s simple and cool. But when you start your own project you can sacrifice convenience for the sake of access to information in Laravel.

I think this is the most factor of Laravel and other frameworks trands.

If CakePHP will create your own detailed howto or cookbook it will have more advantages compared other frameworks and Laravel too. For most your project.

PS. I’m newer in programming and frameworks. But I try study and use Yii2, Laravel and Cake. Yes, I’m dummy in it. But therefore now I really feel why it so hard to start for novice to increase a number of strong users. If it will be interested and organized with Cake community I will can to help with this. I can collect questions, formulate decisions and lead this topic for creating real cookbook, like O’Reilly ) But I need help of profy tor systemizing and this work.


#7

Yes, that is something I did notice.
Like you said, Laravel’s documentation seems to be a lot more detailed as compared to CakePHP, but this is (like you also said) due to the big amount of people using it (with new people joining in every day).

A big point of Laravel is that they have a rather big ecosystem with stuff like Blade (it’s templating engine), Artisan (which is as far as I can tell WAY more powerful than Bake), Horizon, Dusk and Echo.
That’s actually something I sorta “hate” about CakePHP… it doesn’t have awesome tools like those :frowning:


#8

Artisan (which is as far as I can tell WAY more powerful than Bake)

Don’t forget Cake has the console:

bin/cake console

Which let’s you interact with the framework from the CLI just like artisan does in Laravel. I don’t know what the others you mentioned do but wanted to at least mention the Cake console in case you weren’t aware.


#9

I haven’t really played with the console yet, think I should do that…


#10

All have its pluses and minuses.
As for me time is priority. I tried Laravel and I see it will take much more time for me. With Cake you should understand its firstly with some time. But then it will be much more fastly.


#11

All PHP frameworks have some advantages and disadvantages but the most important is to select the good environment according to your needs, laravel or cake, same fight :wink:

I tried many frameworks but I always work with cake for years and we build complex web application with. It’s also useful to make API backend to create a mobile frontend with react-native app :wink:

Anyway, cake’s team are making a great job, especially with the version 3.6.x. The only lack I would say, it’s the documentation, sometimes it’s a challenge to figure out how it works but but nobody is perfect :face_with_monocle:


#12

Cake PHP is a free and very useful development framework for PHP development. This too is a very popular development framework because of its features:
It is a secure framework and helps in authenticating users with ease.
The framework is easy to learn and helps in simplified development of applications
The framework is useful for large sites and applications as it is an MVC driven framework
The site location and configuration are all done by the framework automatically. One only has to connect the database.
One of the key advantages of Cake PHP is that it provides ready to use templates. This makes the process of web application development faster.
The framework is easy to manage and even a lesser experienced developer can work on it with ease.
The framework provides custom testing features which make the testing task quick and simple for developers.
Hence, you have a few good reasons to hire Cake PHP developers for your next web development project.

Laravel is a PHP framework purely meant for developing MVC based applications. It is an open source PHP framework is known to be the finest of the PHP frameworks. Here are some of the key advantages of developing with Laravel:
Laravel helps with enforcing constraints between multiple database objects with the help of an advanced query builder mechanism.
The framework has an auto-loading facility and does not need manual maintenance and inclusion paths.
The framework helps in generating new tools with the help of a LOC container.
The framework provides an easy version control system that helps with simplified management of migrations.
The Laravel framework is fast and easy to setup and customize


#13

The main disadvantage of cakephp is that not many people use it. And there is not a big community, just a handfull of people behind it. And they mostly work for the organisation. So any question soon turns out into either no answers, or requests for payment…


#14

Hi Thomas,

Interesting perception - there are actually a lot of developers who make use of CakePHP, both at a career and a hobby level. Check out the packagist stats to get a good feel of the daily downloads.

We definitely have a good sized community - while there are definitely bigger frameworks out there, its sometimes not the size of a community that is the indication of the quality of the community (or framework).

The team behind CakePHP - the core CakePHP team - is made up of developers who are all incredibly talented and have an immense amount of experience, they do not form part of any paid CakePHP organisation, but rather volunteer all of their time and resources. The core team is made up of individuals who have shown an interest in maintaining and improving the core of the framework as well as supporting other community members on our various support forums.

But the community is more than the core team - we also have community members who you will always see online, chatting and helping others - and we always appreciate every bit of advice, comments and hours of support they offer to others.

CakeDC (the organisation I assume you are referring to?) is the company founded by CakePHP’s co-founder, Larry Masters, as a way to supplement/raise funds towards CakePHP as well as offer CakePHP development services. They are independently run and focus on client work as well as making continuous donations to the CakePHP community through developer time (CakeDC open source plugins, CakePHP Training, CakePHP certifications, CakeFest, Community manager time, servers, software costs, legal costs etc) And financial resources (CakeFest sponsorship etc). They do offer paid-for consultancy should you ever need paid-for support with a CakePHP application.

Community support/free support from other community members can be found on our CakePHP support forums, where everyone is there at their own will, helping out where they can, in their free time - The opensource community is very supportive and the CakePHP Community is always around to help a fellow baker!

Hope that helps answer a few of your questions - but please feel free to reach out to me or others at any time if you have any other questions or would like to get more involved!

Megan
CakePHP Community manager


#15

Cakephp is good except for one thing, they made the querybuilder return nothing if a zero is stored in a tinyint.

If by “querybuilder” you mean the ORM then for a tinyint with value 0 the corresponding entity field in records returns by the ORM will be set to false, that’s not “nothing” :slight_smile:

Since MySQL does not have inbuilt boolean type a tinyint of length 1 is used with 1 corresponding to true and 0 corresponding to false.


#16

If by the “organisation” you mean CakeDC, then you couldn’t be further from the truth :slight_smile:. Of all those listed here https://cakephp.org/pages/team only a couple are employed by CakeDC.

CakeDC is the primary sponsor and manages the various community resources as listed by @Megslalk above but most developers contributing to CakePHP have no direct relation with CakeDC.


#17

I have been doing this stuff since dbase 3

A tinyint field you can store a null if you want to. But I store a 0 or a 1.

If I store a 0, and later loop through to show whats in that field, I expect a 0, not false, not null, not blank.

Doctrine, laravel’s query builder, and orm, native mysql , and even cakephp pdo instance all show a 0. Only cake’s QB and orm show a blank. You doctored the code in the qb and orm to show a blank if a 0 is stored, that is not right.

I am not interested in a boolean true or false, my interest is 1 or 0, which is what I store.

There is no counter point to even be made on this.

I also tested yii2 query builder, a 0 is returned.

I am not trying to argue, but I guess you do it that way to make dealing with a checkbox easier. But a developer should know how to deal with a checkbox, i.e.,

<input type="checkbox" name="adopted" id="adopted" value="1"<?php echo ($cat->adopted == 1 ? ' checked' : ''); ?>>

Im my admin listview I show a 1 or 0, but in an edit view I display a checkbox.


#18

If you don’t like the tinyint(1) being treated as boolean then you have 2 options:

  1. Use tinyint(2)
  2. Override the default type used for tinyint(1) and set it to integer by overriding Table::_initializeSchema().

#19

This became quite an interesting “discussion” :slight_smile:
It’s kinda “meh” that there is a “lack” of third-party support for CakePHP (for example, I used to use a tool called “Skipper18”, but they don’t want to support CakePHP 3.x since there is no demand for it).

Also, sorry for not responding lately, I’ve just been lurking in this thread :slight_smile:


#20

Well I don’t see support for Laravel’s eloquent either :slightly_smiling_face:

Cake’s CLI tool bake can generate ORM classes with associations and validations by introspecting your db tables. As for visualization you can just use something like MySQL workbench. The field types and relations for your db tables are going to be same as your ORM.