Yii2 Vs. Laravel Interesting Results

Cookbook in progress is here: https://github.com/samdark/yii2-cookbook

Indeed most of the docs are using basic app structure in examples. For advanced app configs structure is described in http://www.yiiframework.com/doc-2.0/guide-tutorial-advanced-app.html addressing questions about where to put thing X and how configs will be merged for app Y.

I’ll try checking fixtures link and other stuff.

@Sam

I was stucked on loading fixtures on adavanced app.

I was able to do it on basic, but not advanced

always the same response from Faker module => Error: The template path "@tests/unit/templates/fixtures" does not exist

in my paths I did, trying to respect that was requested and what i tried to understand on documentation

tests\unit\templates\fixtures\DogFixture.php

tests\unit\templates\fixtures\data\dog.php

As I did for basic app; but it fails again and again …

In basic app the fixture/load --templatePath doesn’t exist. I tried to modify it on adavanced but Pfff…

I tried to post some request on Forum but still no response

S.O.S.

OK

I found, sorry for perturbances.

You have to set up the alias in common/config/main.php or main-local.php

setting aliases for @tests in the directory you want

System enforce you to have a templates directory:

tests/unit/templates/fixtures event if it is empty (I don’t really understand the need of those. Sure I miss something)

Then it will grep informations (Fixtures and data) on standard way in test/unit/fixtures

Fixtures path is fixed in master. Will be released with 2.0.1.

I am sorry but documentation on yii2 is not very good,yii team changed lot from yii1 version so people need more help,if you want proof then see what type of issues people asking in forum

And remarks on Yii fixtures Documentation still remain the same. Some links are broken and lead to 404.

Would be great to get pull requests fixing issues mentioned.

Dear ajkosh,

The changes were necessary to make Yii2 better than Yii1.

The Guide and the Cookbook are both WIP. The Guide is usable and better than Yii2 though not complete.

If you have issues just post here and if Bugs at git issue trackers.

We are Yii Community and WE should help make it better than complain to people who gave their time for community good!

@samDark

I do not find such "Fixtures path is fixed in master. Will be released with 2.0.1. "

Is it ?

Thx

Well, yes. I’ve committed changes and these were released in 2.0.1. What’s the problem you experience?

To be direct Sam, I’m lost.

in common bootstrap i set Yii::setAlias(‘tests’, dirname(dirname(DIR)) . ‘/common/tests’);

otherwise it doesn’t work

I use advanced app. I use Faker.

in common\tests\unit\templates\ i have a user.php template (return an array of field)

with yii fixture/generate in

common\tests\unit\fixtures\data a user.php file generated through the one in templates.

And it seems great

BUT

when I launch yii fixture/load user i get





Some fixtures were not found under path:

        C:\Users\Patrick\Documents\Travail\wamp\www\naturo/common/tests/unit/fixtures


Check that they have correct namespace "tests\unit\fixtures"

        1. user


Error: No files were found by name: "user".

Check that files with these name exists, under fixtures path:

"C:\Users\Patrick\Documents\Travail\wamp\www\naturo/common/tests/unit/fixtures".



some mixing between directories and make my head … banging

Here is the entire process:

1- optional:

define @tests. I define it in common bootstrap

2- I define in common\tests\unit\templates\fixtures a user faker template (e.g. user.php)

3- I generate with yii fixture\generate user

it generate a file use.php under common\tests\unit\fixtures\data

in common\tests\unit\fixtures i wrote a UserFixture


namespace tests\unit\fixtures;


use yii\test\ActiveFixture;


class UserFixture extends ActiveFixture

{

    public $modelClass = 'common\models\User';

}



4- I launch yii fixture\load

5- Its works fiiinnnne… Thx to SamDark

6- And I go to bed with headache

https://magora-systems.com/php-framework-comparison-yii-vs-laravel/