yii2 | Yii 2 : The Fast , Secure and Professional PHP Framework | Web Framework library

 by   yiisoft PHP Version: 2.0.48 License: BSD-3-Clause

kandi X-RAY | yii2 Summary

kandi X-RAY | yii2 Summary

yii2 is a PHP library typically used in Server, Web Framework, Framework applications. yii2 has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

Yii 2 is a modern framework designed to be a solid foundation for your PHP application. It is fast, secure and efficient and works right out of the box pre-configured with reasonable defaults. The framework is easy to adjust to meet your needs, because Yii has been designed to be flexible.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              yii2 has a medium active ecosystem.
              It has 14090 star(s) with 7002 fork(s). There are 1090 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 473 open issues and 10943 have been closed. On average issues are closed in 161 days. There are 84 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of yii2 is 2.0.48

            kandi-Quality Quality

              yii2 has 0 bugs and 0 code smells.

            kandi-Security Security

              yii2 has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              yii2 code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              yii2 is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              yii2 releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              yii2 saves you 105412 person hours of effort in developing the same functionality from scratch.
              It has 117646 lines of code, 7292 functions and 1033 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed yii2 and discovered the below as its top functions. This is intended to give you an instant insight into yii2 implemented functionality, and help decide if they suit your requirements.
            • Prepares a framework release .
            • Check for keywords .
            • Converts an ICU date format to PHP date format .
            • Find table columns .
            • Generates doc for class properties .
            • Save messages to database .
            • Convert string value to decimal string
            • Convert color to string
            • Parses given token .
            • Bind action parameters
            Get all kandi verified functions for this library.

            yii2 Key Features

            No Key Features are available at this moment for yii2.

            yii2 Examples and Code Snippets

            No Code Snippets are available at this moment for yii2.

            Community Discussions

            QUESTION

            Yii2 ActiveRecord recommends to call parent constructor after own logic. Isn't this strange?
            Asked 2022-Apr-02 at 06:21

            I'm new to Yii2 and returning to PHP dev after a very long time. I have an extensive background in Java development. I stumbled onto this recommendation in the docs for ActiveRecord:

            __construct() public method

            Defined in: yii\base\BaseObject::__construct()

            Constructor.

            The default implementation does two things:

            • Initializes the object with the given configuration $config.
            • Call init().

            If this method is overridden in a child class, it is recommended that

            • the last parameter of the constructor is a configuration array, like $config here.
            • call the parent implementation at the end of the constructor.

            My question is about the last sentence:

            call the parent implementation at the end of the constructor.

            As a Java dev, this advice seems very weird to me. In Java, not only is it recommended to call the parent constructor as the very first call from your overridden constructor, this is even enforced and it's actually impossible to do it any other way. Either your parent constructor is called first implicitly, or, if you make an explicit call, it MUST be the very first statement in your method. This is enforced by the compiler.

            Theoretically, this makes a lot of sense to me. Because as long as you did not call the parent constructor, your parent class did not have the chance to initialize, so any code you write in the constructor before calling the parent constructor would be working with a half-initialized object.

            Looking at some SO answers I found, they seem to be going against the advice in the official docs and call the parent::__construct before their own custom logic, as I would expect it. For example, the accepted answer in the question How can I create a constructor in a Yii2 model shows an example where they call the parent first:

            ...

            ANSWER

            Answered 2022-Apr-02 at 06:21

            @michal-hynčica correctly stated the reason for your ambiguity(Worthy of votUp).
            But since you mentioned that the official reference, on the same page (BaseObject), this issue is explicitly stated: line

            • In order to ensure the above life cycles, if a child class of BaseObject needs to override the constructor,
            • ....
            • of the constructor, and the parent implementation should be called at the end of the constructor.

            According to the description of this link (similar to your question):
            init () is called which further calls bootstrap () to run bootstrapping components.
            As a result, this is done to ensure configuration. The same process is done in the controller class and the main module.
            Of course, there are many examples like this on the php site (depending on the need) Also read lifecycles and entry script in yii. components and structure-applications. Good luck

            Source https://stackoverflow.com/questions/71691056

            QUESTION

            Moving Bootstrap 3 Modal left in Yii2
            Asked 2022-Mar-14 at 08:42

            I have a Bootstrap 3 Modal that conditionally needs to move to the left so that data on the main page can still be seen when the dialog is open.

            If a

            appears in the modal that has class="modal-left", the modal should appear to the left of the window. Otherwise, it should be rendered as normal on the top center of the screen.

            I am using the Yii2 Modal widget.

            ...

            ANSWER

            Answered 2022-Mar-14 at 08:42

            In your code you start opening modal then you start loading its content right after. The modal showing doesn't wait for content loading. And, the content loading doesn't wait for modal either. So it's basically gamble what will be finished first.

            You can use load() method's complete callback to start showing modal after its content has been load:

            Source https://stackoverflow.com/questions/71460159

            QUESTION

            Yii2 is it possible to toggle onmotion/yii2-widget-apexcharts series by default?
            Asked 2022-Feb-28 at 17:05

            I am using onmotion/yii2-widget-apexcharts. In my chart I have series with ~ 20 data sets but I don't want show them all after page loads (like it's toggled off), instead it would be nice if chart could show only selected series names with option toggle those who are hidden. Primary need is to toggle all series off when page loads, perfect need is toggle off selected series. Can anyone help me with this?

            ...

            ANSWER

            Answered 2022-Feb-28 at 17:05

            You can disable specific series_name by adding JS code to the widget initialization. id is generated, so it can help to specify it explicitly.

            Source https://stackoverflow.com/questions/71248415

            QUESTION

            How do I override a widget method in Yii2?
            Asked 2022-Feb-25 at 06:56

            I need to override the renderPageButton() method in the Yii2 LinkPager widget. The method documentation specifically says "You may override this method to customize the generation of page buttons" but I can't figure out how to do that. Thanks.

            ...

            ANSWER

            Answered 2022-Feb-24 at 12:49

            The class you want to override is documented here.

            You can override it in the following way:

            • Create a new directory in your yii2 app root folder, like widgets
            • Create a new php file (like MyLinkPager.php) and a new class in it (MyLinkPager) which extens yii\widgets\LinkPager
            • You can use "app\widgets" namespace (i.e. if you are working with the basic yii2 app)
            • In your class, implement only the function you want to override from the original class
            • Use your new class wherever you want instead of the original one

            Source https://stackoverflow.com/questions/71188352

            QUESTION

            How can I bcrypt a password during Yii2 Migrations?
            Asked 2022-Feb-02 at 09:35

            I have a question. I have a migration file, that batchInserts an admin user and a normal user into a database. Now I have the files ready and they work fine. However, the password used to have a md5 hash during insert in Yii1.1 something like this: 'password'=>md5('admin')

            My question is, can I do something similar in Yii2 with bcrypt? Where I encrypt the password during creation? I use batchInsert('users', ['column1', 'column2' ...], ['Jon', 'Doe' ...], ['Jane', 'Doe'...])

            Any help is greatly appreciated!

            ...

            ANSWER

            Answered 2022-Feb-02 at 09:35

            The proper way to hash password in Yii2 is using yii\base\Security::generatePasswordHash(). This method uses password_hash() function with PASSWORD_DEFAULT constant as algorithm. I think currently that constant still refers to bcrypt algorithm. But it's meant to be future-proof. When PHP moves to another algorithm you wouldn't need to change your code. If the password_hash() function is not available the generatePasswordHash() methods fallback to crypt() function.

            In migration you can use application components in same way you would use them anywhere else. For example:

            Source https://stackoverflow.com/questions/70952030

            QUESTION

            Fileinput issue in ActiveForm when updating via Yii 2
            Asked 2021-Dec-20 at 12:35

            I am using Yii2 framwork. My file upload function worked well when I upload a single img, while when I click the posed article and I only want to update the post again(Suppose I didn't want to update the img, I only want to update other contents). But I found my uploaded file were replaced with an empty value(varchar type) when I click view. my uploaded img can't show out.

            I do tried to fixed by myself as below, But the existing file value can't be saved when I click the submit button.

            ...

            ANSWER

            Answered 2021-Dec-17 at 09:39

            Add a rule to your model rules:

            Source https://stackoverflow.com/questions/70375242

            QUESTION

            Cannot access sitemap in yii2 project placed in root folder
            Asked 2021-Dec-19 at 09:42

            I have created a sitemap.xml for my yii2 project. I put it in root folder but I can't seem to access it with this URL: https://www.mywebsite.com/sitemap.xml. I need the URL to input it to Google Search Console.

            I've searched everywhere but it seems that information about yii2 and sitemap are very rare.

            What is the correct way to place the sitemap.xml? I believe it can be fixed in htaccess file but I don't know how.

            ...

            ANSWER

            Answered 2021-Dec-13 at 11:19

            QUESTION

            How to run tests from renamed or not default folder?
            Asked 2021-Oct-17 at 11:16

            Yii2 has tests folder structure:

            ...

            ANSWER

            Answered 2021-Oct-17 at 11:16

            The Answer wrote Dmitriy Eliseev from https://yiiframework.ru/forum/viewtopic.php?p=273945#p273945

            It's so simple.

            The suites are picked up from *.suite.yml files.

            So,in addition to unit.suite.yml and functional.suite.yml inside tests folder you should add an integrational.suite.yml file with settings. In this case tests from integrational folder will be work as well.

            Source https://stackoverflow.com/questions/69572360

            QUESTION

            Yii2 set MySQL user for first time migration table creation?
            Asked 2021-Oct-16 at 15:13

            My issue has to do with the automated creation of the migration history table when first executing yii migrate/up --interactive=0.
            I was able to override the database access credentials for the migrations themselves. (see example below)

            For my web application, I have a user default that has the following GRANTs: SELECT, INSERT For migrations, I want to use my admin user who has additional GRANTs for DDL.

            When executing the migration Yii2 wants to create a migration table with the default user which leads to a permission denied error.

            How can I set the database user for the migration table creation?

            My migration script:

            ...

            ANSWER

            Answered 2021-Oct-16 at 15:13

            Migrations are run from console.

            That means, the console.php config file is loaded instead of your main.php config. So one way, that would also affect any other console commands you might have, would be to change the db configuration in the components section of the console config.

            config\console.php:

            Source https://stackoverflow.com/questions/69091503

            QUESTION

            Yii2 NavBar forcing load of extra Bootstrap
            Asked 2021-Sep-26 at 12:45

            I'm attempting to adapt the Heroic Features template from Start Bootstrap to Yii2.

            The heroic-features.css includes Bootstrap & I like to use CDNs where I can, so I've overridden YiiAsset, JqueryAsset, & BootstrapAsset.

            Everything looks good until I include the NavBar.

            In frontend/views/layouts/main.php I have everything bootstrap5...

            ...

            ANSWER

            Answered 2021-Sep-26 at 12:45

            Don't use bootstrap navbar it will internally register bootstrap plugin asset. You need to customize the navbar as well.

            Yii2 Bootstrap NavrBar

            Source https://stackoverflow.com/questions/69326121

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install yii2

            The minimum required PHP version of Yii is PHP 5.4.
            It works best with PHP 7.
            Follow the Definitive Guide in order to get step by step instructions.

            Support

            A Definitive Guide and a Class Reference cover every detail of the framework.There is a PDF version of the Definitive Guide and a Definitive Guide Mirror which is updated every 15 minutes.For Yii 1.1 users, there is Upgrading from Yii 1.1 to get an idea of what has changed in 2.0.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/yiisoft/yii2.git

          • CLI

            gh repo clone yiisoft/yii2

          • sshUrl

            git@github.com:yiisoft/yii2.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link