GithubHelp home page GithubHelp logo

yii2-cookbook's Introduction

yii2-cookbook's People

Contributors

7audio avatar acorncom avatar aik84from avatar annechko avatar arogachev avatar cronfy avatar dhoomm avatar dmytroraschepkin avatar exploitfate avatar faryshta avatar forevermatt avatar githubjeka avatar iadj avatar ilyaplot avatar langshuang avatar markch123 avatar nikolai-katkov avatar o-rey avatar pana1990 avatar pantsarny avatar petrabarus avatar ptheofan avatar razoramon avatar robinkamps avatar samdark avatar silverfire avatar tbreuss avatar tunecino avatar ufoproger avatar user1007017 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-cookbook's Issues

Disabling debug toolbar runtime

if (class_exists('\yii\debug\Module')) {
    $this->off(\yii\web\View::EVENT_END_BODY, [\yii\debug\Module::getInstance(), 'renderToolbar']);
}

Translation in Modules

I think it will be good to have few recipes on translating Modules.
Module can share messages via app catalog but for third-party modules, separate message is essential

Using IDs in translations instead of full strings

Force translation in messages source:

'components' => [
        'i18n' => [
            'translations' => [
                'app*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@app/messages',
                    'sourceLanguage' => 'en_US',
                    'forceTranslation' => true, // <---- HERE!
                ],
            ],
        ],

Elasticsearch

Would be an interesting chapter
What it is?
What you need?
How to?
Why? (for what)

Form validation not working with bootstrap model

Hi,

I have used model for the popup form but i am facing one problem using this form validation working so far. Could any one can helps me to figured out this issue.

Here is my code

public function actionCreate(){
$model = new AttributeGroup();

    if ($model->load(Yii::$app->request->post()) && $model->save()) {
        return $this->redirect(['']);
    } else {
        return $this->renderAjax('create', ['model' => $model,]);

    }

}

Url::to(['attributesetgroup/create']), 'id' => 'modalButton', 'class' => 'btn btn-success']) ?>
        <?php echo Html::button('Delete Selected Group', ['value' => Url::to(['attributesetgroup/test']), 'id' => 'modalButton', 'class' => 'btn btn-warning']) ?>
        <?php
            Modal::begin([
                'id' => 'modal',
                'header'=>'Attribute Group'
            ]);
            echo "<div id='modalContent'></div>";

            Modal::end();
        ?>

$('#modalButton').click(function (){
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});

// serialize form, render response and close modal
function submitForm($form) {
$.post(
$form.attr("action"), // serialize Yii2 form
$form.serialize()
)
.done(function(result) {
$form.parent().html(result.message);
$('#modal').modal('hide');
})
.fail(function() {
console.log("server error");
$form.replaceWith('Fail').fadeOut()
});
return false;
}

If i will check the response in firefox console than i can see there is error message display on the response but its seem not working on form.

Please help me to figured out this issue.

Thanks in advance.

Regards,
Jignesh

Structure: backend and frontend via modules (Suggestion)

It was great Idea, but I have one issue while applying it.
Now with what we have, I can open blogFrontend or blogBackend regardless of the current running application. So it would be great if you can mention some way to automate this routing between backend and frontend. I would like to know what do you think? how can I restrict this? (See the following links).

http://example.com/frontend/blog/   == will take you to ==> blog-frontend
http://example.com/backend/blog/  == will take you to ==> blog-backend

Note: I'm not talking about pretty urls, I'm talking about current running application.

Testing & debuggin section

How about having a dedicated chapter for testing & debugging:

  • unit testing
  • integration testing
  • selenium
  • IDE
  • XDebug
  • debug toolbar
  • gii
  • error logging
  • codeception ?
  • ...

Cookie Problem on I18n selecting application language

This documents are perfect but having some problems.
In I18n selecting application language page

$languageCookie = new Cookie([
    'name' => 'language',
    'value' => $language,
    'expire' => 60 * 60 * 24 * 30, // 30 days
]);
Yii::$app->request->cookies->add($languageCookie);

I think its should be

$languageCookie = new Cookie([
    'name' => 'language',
    'value' => $language,
    'expire' => time() + (60 * 60 * 24 * 30), // 30 days
]);
Yii::$app->response->cookies->add($languageCookie);

thanks.

About IDE autocompletion for Yii::createObject

/**
* add question follow
*/
public function dealWithAddFollowQuestion()
{
        $model = Yii::createObject(FollowQuestionEntity::className());
        $model->addFollow($this->owner->id, $this->owner->create_by);
}

$model is created by Yii::createObject
And how to let $model auto hints?

How to use DI Container (suggestion)

I will be nice if the book will have a section that show how to use yii\di\Container and how it can help to decouple the business logic from the framework.

Use readYAML instead of readJSON with Grunt (suggestion)

Regarding the chapter "Asset processing with Grunt". Instead of creating an all.json file, there is a benefit to creating a YAML file instead. The benefit is that comments are allowed in a YAML file, but not in JSON.

In your Gruntfile.js you can do this:

'web/js/all.js': grunt.file.readYAML('assets/js/all.yml')

instead of this:

'web/js/all.js': grunt.file.readJSON('assets/js/all.json')

The all.yml YAML file should look like this:

- vendor/bower/jquery/dist/jquery.js
- vendor/bower/bootstrap/dist/js/bootstrap.js
- vendor/yiisoft/yii2/assets/yii.js
- vendor/yiisoft/yii2/assets/yii.validation.js
- vendor/yiisoft/yii2/assets/yii.activeForm.js

So now you can do something like this, which can be really handy:

- vendor/bower/jquery/dist/jquery.js
#- not using bootstrap now, but may want to use it in the future
#- vendor/bower/bootstrap/dist/js/bootstrap.js
- vendor/yiisoft/yii2/assets/yii.js
- vendor/yiisoft/yii2/assets/yii.validation.js
- vendor/yiisoft/yii2/assets/yii.activeForm.js

yii2 cookbook(chinese version)

Hello. I'm trying to make a chinese version of yii 2 cookbook. May I just fork the file and start translating? (Sorry its my first time, quite nervous about translating things on github)

Any suggestion are welcome. Thank you.

OAuth2 Server

Well I think Yii2 have clients to Utilize Services. But I have found Yii2 and OAuth2 server Interesting. I found [https://github.com/Filsh/yii2-oauth2-server] and its interesting. Wanted to know if its valid for this cookbook.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.