What's all this fuss with Laravel ?

I am not sure why dotenv is even needed when we can do stuff like this:


    	'db' => require(__DIR__ . '/db.php'),



And as long as we put db.php in our gitignore, we are fine.

The advanced template has environment support and I think it is clean, easy to use and secure and performant.

Personally, I think using environment variables - or even relying on them - in whatever mode you are in, is a bad design decision.

I used to use it in my other programming projects (graphics C++, CMake, etc) but I think it is brittle.

It also pollutes the global environment (literally).

I don’t use them any more.

Fair point, however, thing is that in this way you never have a definition of what’s inside db.php. I mean, if i clone your repo, how do i know what i suppose to put there, or that i suppose to create a db.php file?

I think that’s what dotenv fixes, the fact that you can ship your configuration as is using env placeholders which each developer can load from his own env.

L.E: Just reading https://github.com/vlucas/phpdotenv/issues/76 so it seems this is a no go ;)

I usually put a db.php.in file with placeholder values and a pre configured gitignore, and I had an interactive install script once upon a time.

I just recalled one more thing.

At the time of my learning, Yii 1.1 was virtually the fastest full-stack framework in the PHP world. It promised much more speed and rich functionality than others. Yii 1.1 indeed provided it. And it helped me from going back to CI, putting up with the initial hard times.

Now, I wonder what can Yii 2 promise to the new comers?

Speed? Yes, it is fast enough. But not the fastest.

Full-stack functionality? Yes, it is. But Laravel also can provide it.

Is it easy to learn and easy to use? Umm, yes, it probably is …

Well, then, what is the sales point of Yii 2?

We need some killer feature in Yii 2 that others can’t provide.

Throw my 2 cents in, but I can’t compare to Laravel but to c# visual studio.

I often found the language and the million ways to skin a cat in web apps to be a pain, I also found that the components were constantly getting in the way of the developer.

Being a php develop for a dozen+ years, I never strayed far from the language, especially for the web. It is quick, seemless and do just about anything.

THE OTHER REASON I and I believe other fell in love with PHP is because of the documentation. The documentation is not great, BUT, people posted tons of useful comments at the end of the docs for each function or method. IT WAS TREMENDOUS. It is what made learning PHP so easy.

I decided to give YII2 a try out a couple of months ago, and I will say it has not been easy. BUT, I have grown fond of it. And I love the tiny memory footprint. Being a performance freak, marrying myself to a framework took along time, and a long time was to long. YII and other frameworks get allot of redundancy out of the way. I love activerecord, RBAC, quick code generation.

And since I can;t offer much in docs because I am new…

DOCS do kind of suck. I am hoping those reading this have some pull and go look at how PHP did there documentation and allowing users to post comments such as example code.

And because the docs kind of suck, it makes learning YII a bit daunting.

If you can handle laravel, you can handle yii. If you want performance, go with yii. From all the studying I did on frameworks before settling, I believe I made the right choice.

One last thing, their is a couple of books out on YII2 now. I picked them both up a couple of days ago. Have not looked at em yet, so no review.

I think you will like the fact that the new Yii site will feature user comments for guide and API :)

And, most importantly: the pages of the guide has a link that enables users to edit the documentation on Github and issue a pull request.

I am still a bit new to Yii 2 but it feels a lot less clunky than Yii 1.

It is easier to customize because the API is more flexible/fluent.

It feels a lot more streamlined.

That is my highly unprofessional review of Yii 2.

The single most important upgrade has to be full fledged Composer support.

Installation of Yii and extensions is definitely a lot less painful.

And the ability to use Composer projects is also great.

The would be great. I really believe it is why PHP became so popular, because the documentation was straight forward, BUT the greatest part was the useful code and comments that were posted with the functions / classes at the bottom of the page. If ever in doubt you can almost always find a post at PHP’s site under a function that will give you direction if not answering the very question you are looking for.

To me, the bests features that Yii have are:

[list=1]

[*]complete code generate (for simple apps and sites it is perfect, you don’t spend time to cread the same thing);

[*]components;

[*]2 tamplates to choose, basic and advanced

[/list]

I Agree with you. I think that Yii 2 is easier to customize and configure than Yii 1.

In our company we are using Yii.1 from last 4 year, just now started 2 project with Yii2.

According to my experience what problems we faced one of the main problem is Yii2 need special setup on server but most of clients have place project on shared server, so in Yii2 its problem where we need special server configurations.

Second we have old php version on our development server, Centos by default insstall php 5.3 where for Yii2 minimum requirement is 5.4

so that’s why from last 6 months we were avoiding to use Yii2 for next projects.

but we step up and configured one server with PHP 5.5 and started working on Yii2

So from all the concerns i think Yii2 is future of PHP fameworks, it have beautiful code structures and high end vendor management.

Yii2 is have very advance concepts and it is for long run, Laravel is looks more fancy, new commer always like fancy things.

I have seen this quote in top of google search from one radical fan of Laravel:

so now we can say Yii2 is secular and Laravel is communal.

Yii2 itself doesn’t need any special virtual host configuration. The default Yii1 directory structure (with the “protected” directory) can be easily recreated with Yii2. (EDIT: it’s not recommended unless you have absolutely no choice, but possible) The problem is that the documentation suggests that the only way to start a Yii2 project is to use an application template which is not true.

I think he meant intl, mbstring etc.

I agree.

One of the sites that I maintain is a shared host that supports

  • PHP 4.4

  • PHP 5.2

  • PHP 5.3

  • PHP 5.4

  • PHP 5.6

But its PHP 5.4 doesn’t support INTL.

And the PHP 5.6 also doesn’t support INTL. And what’s worse, it has a critical problem with Composer.

But IMO we should not take too much care of the shared hosts.

As you see in the common discussions like "what should I do to use the advanced tmplate with my shared host", it tends to make things complicated and tricky.

[EDIT]

OK, I finally configured it successfully. Now it runs PHP 5.6 with INTL and Composer.

Sorry for the OT.

Yii2 guideline should share some good practices to configure yii2 on shared hosting without /web folder, i found some help on google but it is non official tricks.

I don’t think that Yii should ever officially recommend bad practice.

I’ve used Dreamhost shared hosting and never had a problem with it.

If you are on shared hosting that does not allow you to specify the web root, then simply move to a shared hosting provider that does support it.

And if that is not an option, Google for non-official work arounds.

There are several listed in the Yii wiki.

Yii cannot and should not officially encourage you to install everything in the web root.

A bit OT, but the practical app a from Kartik is one of the best solutions to the shared host problem: https://github.com/kartik-v/yii2-app-practical-a - highly recommended if you can’t set the web root and when you want to use a frontend/backend application structure.

Personally I think Yii has to follow the trend of microframeworks which showed up on the market “recently”. Yii has to be more decoupled so that more developers could use the libraries they picked them by themselves. Recently I was looking for a fast, simple and lightweight microframework. Finally I got into slimframework.com. It was so easy to establish a simple rest service and to start using it. I did it really fast without any knowledge about this particular framework. On the other hand slimframework is very powerfull (Yii is too but in a matter of time you have to spend to get into it, it’s a hidden power).

Also we have to remeber, that webservices (or websites) are going to be splitted into small, independent microservices - easy to get into, manage, deploy.

We have to simplfy the framework because it’s too compliacated for newbies and decouple it to be more resuable.

Well,

Microframeworsk are great, indeed, but well - there are so many various demands it’s practically impossible to handle all of them in a single structure.

Indeed, what is probably the biggest obstacle of using Yii2 is that one has to be experienced to catch how to pass arguments to various components what is often poorly documented.

For instance, presume one needs to format value in the activeForm input field, e.g.:

$form->field($model, $argument, [‘inputOptions’ => [‘value’ => Yii::$app->formatter->asDecimal($model->$argument, 2)]]);

Finding that actually inputOptions’ value property of the form field has to be used can be really tricky for a beginner and documentations is a bit dry in case of real live usage scenarios.

Second - it would be great to have some real "helicopter view" of the Yii2 application.

For instance - it took me quite a good time to understand how all key components play together! It took me some time to understand what routing actually is, what bootstraping is for, how to use asset bundles etc.

Definitely - there are too many "cookbooks" out there what show instant solutions but suffer of lack of deeper understanding why and how.

Last but not least - there is still very few real life examples of proper usage of the Yii2’s DI container what is the reason Yii2 is still not seen as “modern enough”. This is a crucial point IMHO - promotion of clever usage of dependency injection is priority for Yii2 proliferation.

Maybe, but I strongly disagree that Yii be catering for newbies.

Pardon my French, but fuck newbies :)

Let other frameworks simplify and perhaps even dumb down their frameworks, Yii should not do that.

Because then it will end up doing things for the user, and that is not a good route to take.

I like Yii because it treats me with respect. :)

However, I do agree that it is always a good idea to improve the framework - without compromising :)