목차
yii2源码学习笔记(十二),yii2源码学习笔记
백엔드 개발 PHP 튜토리얼 yii2源码学习笔记(十二),yii2源码学习笔记_PHP教程

yii2源码学习笔记(十二),yii2源码学习笔记_PHP教程

Jul 12, 2016 am 08:51 AM
yii

yii2源码学习笔记(十二),yii2源码学习笔记

继续了解controller基类。

    <span>/*</span><span>*
     * Runs a request specified in terms of a route.在路径中指定的请求。
     * The route can be either an ID of an action within this controller or a complete route consisting
     * of module IDs, controller ID and action ID. If the route starts with a slash '/', the parsing of
     * the route will start from the application; otherwise, it will start from the parent module of this controller.
     * 该路径可以是控制器内的一个动作的标识,或由模块标识、控制器标识和动作标识组成的一个完整路径。
     * 如果该路径从一个&ldquo;/&rdquo;开始,该路径的解析将从应用程序开始;否则,它将从该控制器的父模块开始。
     * @param string $route the route to be handled, e.g., 'view', 'comment/view', '/admin/comment/view'.
     * @param array $params the parameters to be passed to the action.
     * @return mixed the result of the action.
     * @see runAction()
     </span><span>*/</span>
    <span>public</span> function run($route, $<span>params</span> =<span> [])
    {
        $pos </span>= strpos($route, <span>'</span><span>/</span><span>'</span><span>);
        </span><span>if</span> ($pos === <span>false</span>) {<span>//</span><span>判断是否以&ldquo;/&rdquo;开始 是则解析从应用程序开始;否则,它将从该控制器的父模块开始。</span>
            <span>return</span> $<span>this</span>->runAction($route, $<span>params</span><span>);
        } elseif ($pos </span>> <span>0</span><span>) {
            </span><span>return</span> $<span>this</span>->module->runAction($route, $<span>params</span><span>);
        } </span><span>else</span><span> {
            </span><span>return</span> Yii::$app->runAction(ltrim($route, <span>'</span><span>/</span><span>'</span>), $<span>params</span><span>);
        }
    }

    </span><span>/*</span><span>*
     * Binds the parameters to the action.将参数绑定到动作标识。
     * This method is invoked by [[Action]] when it begins to run with the given parameters.
     * 运行给定的参数时,该方法被调用。
     * @param Action $action the action to be bound with parameters.参数约束的操作。
     * @param array $params the parameters to be bound to the action.要约束的参数。
     * @return array the valid parameters that the action can run with.可以运行的有效参数。
     </span><span>*/</span>
    <span>public</span> function bindActionParams($action, $<span>params</span><span>)
    {
        </span><span>return</span><span> [];
    }

    </span><span>/*</span><span>*
     * Creates an action based on the given action ID. 根据给定的操作标识创建一个action。
     * The method first checks if the action ID has been declared in [[actions()]]. If so,
     * it will use the configuration declared there to create the action object.
     * If not, it will look for a controller method whose name is in the format of `actionXyz`
     * where `Xyz` stands for the action ID. If found, an [[InlineAction]] representing that
     * method will be created and returned.
     * 该方法首先检查动作标识是否在 [[actions()]]设置,如果是将使用配置声明来创建操作对象。
     * 如果不是,它会寻找控制器方法`Xyz` 的 `actionXyz`作为动作标识,调用[[InlineAction]]方法创建对象
     * @param string $id the action ID. 
     * @return Action the newly created action instance. Null if the ID doesn't resolve into any action.
     </span><span>*/</span>
    <span>public</span><span> function createAction($id)
    {
        </span><span>if</span> ($id === <span>''</span><span>) {
             </span><span>//</span><span> 如果action的id为空,就是用默认的action</span>
            $id = $<span>this</span>-><span>defaultAction;
        }

        $actionMap </span>= $<span>this</span>->actions();<span>//</span><span> 获取actions方法中的定义的actionMap</span>
        <span>if</span><span> (isset($actionMap[$id])) {
             </span><span>//</span><span> 如果操作标识在actionMap中,就去创建这个action</span>
            <span>return</span> Yii::createObject($actionMap[$id], [$id, $<span>this</span><span>]);
        } elseif (preg_match(</span><span>'</span><span>/^[a-z0-9\\-_]+$/</span><span>'</span>, $id) && strpos($id, <span>'</span><span>--</span><span>'</span>) === <span>false</span> && trim($id, <span>'</span><span>-</span><span>'</span>) ===<span> $id) {
             </span><span>//</span><span> 如果id符合命名规范,而且两边不存在-
            </span><span>//</span><span> 用于拼接controller类名类似的方法拼接action方法的名称</span>
            $methodName = <span>'</span><span>action</span><span>'</span> . str_replace(<span>'</span> <span>'</span>, <span>''</span>, ucwords(implode(<span>'</span> <span>'</span>, explode(<span>'</span><span>-</span><span>'</span><span>, $id))));
            </span><span>if</span> (method_exists($<span>this</span><span>, $methodName)) {
                </span><span>//</span><span> 如果方法存在,就实例化</span>
                $method = <span>new</span> \ReflectionMethod($<span>this</span><span>, $methodName);
                </span><span>if</span> ($method->isPublic() && $method->getName() ===<span> $methodName) {
                    </span><span>//</span><span> 如果方法是public的,就new一个InlineAction返回</span>
                    <span>return</span> <span>new</span> InlineAction($id, $<span>this</span><span>, $methodName);
                }
            }
        }

        </span><span>return</span> <span>null</span><span>;
    }

    </span><span>/*</span><span>*
     * This method is invoked right before an action is executed.
     * 在执行操作之前调用此方法。
     * The method will trigger the [[EVENT_BEFORE_ACTION]] event. The return value of the method
     * will determine whether the action should continue to run.
     * 方法将触发 [[EVENT_BEFORE_ACTION]] 事件,返回值确定该操作是否执行
     * If you override this method, your code should look like the following:
     *
     * ```php
     * public function beforeAction($action)
     * {
     *     if (parent::beforeAction($action)) {
     *         // your custom code here
     *         return true;  // or false if needed
     *     } else {
     *         return false;
     *     }
     * }
     * ```
     *
     * @param Action $action the action to be executed. 执行的操作
     * @return boolean whether the action should continue to run.确定操作是否应该继续运行。
     </span><span>*/</span>
    <span>public</span><span> function beforeAction($action)
    {
        $</span><span>event</span> = <span>new</span><span> ActionEvent($action);
        $</span><span>this</span>->trigger(self::EVENT_BEFORE_ACTION, $<span>event</span><span>);
        </span><span>return</span> $<span>event</span>-><span>isValid;
    }

    </span><span>/*</span><span>*
     * This method is invoked right after an action is executed.
     * 在执行操作之后调用此方法。
     * The method will trigger the [[EVENT_AFTER_ACTION]] event. The return value of the method
     * will be used as the action return value.
     *
     * If you override this method, your code should look like the following:
     *
     * ```php
     * public function afterAction($action, $result)
     * {
     *     $result = parent::afterAction($action, $result);
     *     // your custom code here
     *     return $result;
     * }
     * ```
     *
     * @param Action $action the action just executed. 刚刚执行的操作。
     * @param mixed $result the action return result. 操作返回值
     * @return mixed the processed action result. 处理结果。
     </span><span>*/</span>
    <span>public</span><span> function afterAction($action, $result)
    {
        $</span><span>event</span> = <span>new</span><span> ActionEvent($action);
        $</span><span>event</span>->result =<span> $result;
        $</span><span>this</span>->trigger(self::EVENT_AFTER_ACTION, $<span>event</span><span>);
        </span><span>return</span> $<span>event</span>-><span>result;
    }

    </span><span>/*</span><span>*
     * Returns all ancestor modules of this controller. 获取当前控制器所有的父模块
     * The first module in the array is the outermost one (i.e., the application instance),
     * while the last is the innermost one.
     * 数组中的第一个模块是最外层的一个,最后一个模块是最内层的。
     * @return Module[] all ancestor modules that this controller is located within.当前控制器所有的父模块
     </span><span>*/</span>
    <span>public</span><span> function getModules()
    {
        </span><span>//</span><span> 当前controller的module组成的数组</span>
        $modules = [$<span>this</span>-><span>module];
        $module </span>= $<span>this</span>-><span>module;
        </span><span>while</span> ($module->module !== <span>null</span><span>) {
             </span><span>//</span><span> 将外面的module插入到modules数组的开头</span>
            array_unshift($modules, $module-><span>module);
            $module </span>= $module-><span>module;
        }
        </span><span>return</span><span> $modules;
    }

    </span><span>/*</span><span>*
     * @return string the controller ID that is prefixed with the module ID (if any).
     * 返回控制器id
     </span><span>*/</span>
    <span>public</span><span> function getUniqueId()
    {
        </span><span>//</span><span>如果当前所属模块为application,则就为当前id,否则要面要加上模块id</span>
        <span>return</span> $<span>this</span>->module instanceof Application ? $<span>this</span>->id : $<span>this</span>->module->getUniqueId() . <span>'</span><span>/</span><span>'</span> . $<span>this</span>-><span>id;
    }

    </span><span>/*</span><span>*
     * Returns the route of the current request.    获取默认请求的路由信息
     * @return string the route (module ID, controller ID and action ID) of the current request. 
     * 当前请求的路由(模块标识、控制器标识和操作标识)
     </span><span>*/</span>
    <span>public</span><span> function getRoute()
    {
        </span><span>return</span> $<span>this</span>->action !== <span>null</span> ? $<span>this</span>->action->getUniqueId() : $<span>this</span>-><span>getUniqueId();
    }

    </span><span>/*</span><span>*
     * Renders a view and applies layout if available.
     * 如果有布局渲染视图文件和布局文件
     * The view to be rendered can be specified in one of the following formats:
     *
     * - path alias (e.g. "@app/views/site/index");
     * - absolute path within application (e.g. "//site/index"): the view name starts with double slashes.
     *   The actual view file will be looked for under the [[Application::viewPath|view path]] of the application.
     * - absolute path within module (e.g. "/site/index"): the view name starts with a single slash.
     *   The actual view file will be looked for under the [[Module::viewPath|view path]] of [[module]].
     * - relative path (e.g. "index"): the actual view file will be looked for under [[viewPath]].
     *
     * To determine which layout should be applied, the following two steps are conducted:
     * 确定应用布局文件类型的步骤:
     * 1. In the first step, it determines the layout name and the context module:
     * 首先确定布局文件名和背景模块
     * - If [[layout]] is specified as a string, use it as the layout name and [[module]] as the context module;
     * - If [[layout]] is null, search through all ancestor modules of this controller and find the first
     *   module whose [[Module::layout|layout]] is not null. The layout and the corresponding module
     *   are used as the layout name and the context module, respectively. If such a module is not found
     *   or the corresponding layout is not a string, it will return false, meaning no applicable layout.
     *   如果布局文件是字符串,也就是设置布局文件,则直接调用。 如果没有设置布局文件,则查找所有的父模块的布局文件。
     * 2. In the second step, it determines the actual layout file according to the previously found layout name
     *    and context module. The layout name can be:
     *    应用下的布局文件,以&ldquo;/&rdquo;开头,这个会从应用程序的布局文件目录下面查找布局文件
     * - a path alias (e.g. "@app/views/layouts/main");
     * - an absolute path (e.g. "/main"): the layout name starts with a slash. The actual layout file will be
     *   looked for under the [[Application::layoutPath|layout path]] of the application;
     * - a relative path (e.g. "main"): the actual layout file will be looked for under the
     *   [[Module::layoutPath|layout path]] of the context module.
     *
     * If the layout name does not contain a file extension, it will use the default one `.php`.
     * 如果布局文件没有扩展名,则默认为.php
     * @param string $view the view name.
     * @param array $params the parameters (name-value pairs) that should be made available in the view.
     * These parameters will not be available in the layout.
     * @return string the rendering result.
     * @throws InvalidParamException if the view file or the layout file does not exist.
     </span><span>*/</span>
    <span>public</span> function render($view, $<span>params</span> =<span> [])
    {
        </span><span>//</span><span>由view对象渲染视图文件</span>
        $content = $<span>this</span>->getView()->render($view, $<span>params</span>, $<span>this</span><span>);
        </span><span>return</span> $<span>this</span>->renderContent($content);<span>//</span><span>渲染布局文件</span>
<span>    }

    </span><span>/*</span><span>*
     * Renders a static string by applying a layout.    配合render方法渲染布局文件
     * @param string $content the static string being rendered  被渲染的静态字符串
     * @return string the rendering result of the layout with the given static string as the `$content` variable.
     * If the layout is disabled, the string will be returned back.
     * 以给定的静态字符串作为&ldquo;$content&rdquo;变量布局的渲染结果。如果布局被禁用,将返回该字符串。
     * @since 2.0.1
     </span><span>*/</span>
    <span>public</span><span> function renderContent($content)
    {
        $layoutFile </span>= $<span>this</span>->findLayoutFile($<span>this</span>->getView()); <span>//</span><span>查找布局文件</span>
        <span>if</span> ($layoutFile !== <span>false</span>) {<span>//</span><span>由view对象渲染布局文件,并把上视图结果作为content变量传递到布局中,</span>
            <span>return</span> $<span>this</span>->getView()->renderFile($layoutFile, [<span>'</span><span>content</span><span>'</span> => $content], $<span>this</span><span>);
        } </span><span>else</span><span> {
            </span><span>return</span><span> $content;
        }
    }

    </span><span>/*</span><span>*
     * Renders a view without applying layout.渲染视图文件不应用布局
     * This method differs from [[render()]] in that it does not apply any layout.
     * 这种方法不同于[[render()]],它不使用任何布局。
     * @param string $view the view name. Please refer to [[render()]] on how to specify a view name.
     * 视图名称。根据[[render()]]指定一个视图名称。
     * @param array $params the parameters (name-value pairs) that should be made available in the view.
     * 在视图中提供的参数(name-value pairs)
     * @return string the rendering result.渲染结果。
     * @throws InvalidParamException if the view file does not exist.如果视图文件不存在,抛出异常
     </span><span>*/</span>
    <span>public</span> function renderPartial($view, $<span>params</span> =<span> [])
    {
        </span><span>return</span> $<span>this</span>->getView()->render($view, $<span>params</span>, $<span>this</span><span>);
    }

    </span><span>/*</span><span>*
     * Renders a view file. 渲染一个文件
     * @param string $file the view file to be rendered. This can be either a file path or a path alias.
     * 要呈现的视图文件。可以是一个文件路径或路径别名。
     * @param array $params the parameters (name-value pairs) that should be made available in the view.
     * 在视图中提供的参数(name-value pairs)
     * @return string the rendering result.渲染结果
     * @throws InvalidParamException if the view file does not exist.如果视图文件不存在,抛出异常
     </span><span>*/</span>
    <span>public</span> function renderFile($file, $<span>params</span> =<span> [])
    {
        </span><span>return</span> $<span>this</span>->getView()->renderFile($file, $<span>params</span>, $<span>this</span><span>);
    }

    </span><span>/*</span><span>*
     * Returns the view object that can be used to render views or view files.
     * 返回渲染视图或视图文件的view对象。
     * The [[render()]], [[renderPartial()]] and [[renderFile()]] methods will use
     * this view object to implement the actual view rendering.
     * [[render()]], [[renderPartial()]] and [[renderFile()]] 方法将使用视图对象实现视图显示。
     * If not set, it will default to the "view" application component.如果未设置,则默认为&ldquo;view&rdquo;应用程序组件。
     * @return View|\yii\web\View the view object that can be used to render views or view files.
     * 渲染视图或视图文件的view对象。
     </span><span>*/</span>
    <span>public</span><span> function getView()
    {
        </span><span>if</span> ($<span>this</span>->_view === <span>null</span><span>) {
            $</span><span>this</span>->_view = Yii::$app-><span>getView();
        }
        </span><span>return</span> $<span>this</span>-><span>_view;
    }

    </span><span>/*</span><span>*
     * Sets the view object to be used by this controller.
     * @param View|\yii\web\View $view the view object that can be used to render views or view files.
     </span><span>*/</span>
    <span>public</span><span> function setView($view)
    {
        $</span><span>this</span>->_view =<span> $view;
    }

    </span><span>/*</span><span>*
     * Returns the directory containing view files for this controller.返回该控制器包含视图文件的目录。
     * The default implementation returns the directory named as controller [[id]] under the [[module]]'s
     * [[viewPath]] directory.默认返回目录命名为控制器[[id]] 下的 [[module]]的[[viewPath]]目录。
     * @return string the directory containing the view files for this controller.
     * 包含此控制器的视图文件的目录。
     </span><span>*/</span>
    <span>public</span><span> function getViewPath()
    {
        </span><span>return</span> $<span>this</span>->module->getViewPath() . DIRECTORY_SEPARATOR . $<span>this</span>-><span>id;
    }

    </span><span>/*</span><span>*
     * Finds the applicable layout file.查找适用的布局文件。
     * @param View $view the view object to render the layout file.呈现布局文件视图对象。
     * @return string|boolean the layout file path, or false if layout is not needed.
     * Please refer to [[render()]] on how to specify this parameter.
     * 布局文件路径,或者不需要布局。参阅[[render()]]如何指定此参数。
     * @throws InvalidParamException if an invalid path alias is used to specify the layout.
     * 如果使用了无效的路径别名指定布局。抛出异常
     </span><span>*/</span>
    <span>public</span><span> function findLayoutFile($view)
    {
        $module </span>= $<span>this</span>-><span>module;
        </span><span>if</span> (is_string($<span>this</span>-><span>layout)) {
             </span><span>//</span><span>如果当前控制器设置了布局文件,则直接使用所设置的布局文件</span>
            $layout = $<span>this</span>-><span>layout;
        } elseif ($</span><span>this</span>->layout === <span>null</span><span>) {
             </span><span>//</span><span>如果没有设置布局文件,查找所有的父模块的布局文件。</span>
            <span>while</span> ($module !== <span>null</span> && $module->layout === <span>null</span><span>) {
                $module </span>= $module-><span>module;
            }
            </span><span>if</span> ($module !== <span>null</span> && is_string($module-><span>layout)) {
                $layout </span>= $module-><span>layout;
            }
        }

        </span><span>if</span> (!<span>isset($layout)) {
            </span><span>return</span> <span>false</span>;<span>//</span><span>如果没有设置布局文件,返回false</span>
<span>        }

        </span><span>if</span> (strncmp($layout, <span>'</span><span>@</span><span>'</span>, <span>1</span>) === <span>0</span><span>) {
            $file </span>= Yii::getAlias($layout);<span>//</span><span>以&ldquo;@&rdquo;开头,会在别名路径中查找布局文件</span>
        } elseif (strncmp($layout, <span>'</span><span>/</span><span>'</span>, <span>1</span>) === <span>0</span>) {<span>//</span><span>以&ldquo;/&rdquo;开头,会从应用程序的布局文件目录下面查找布局文件</span>
            $file = Yii::$app->getLayoutPath() . DIRECTORY_SEPARATOR . substr($layout, <span>1</span><span>);
        } </span><span>else</span> {<span>//</span><span>从当前模块的布局文件目录下查找布局文件</span>
            $file = $module-><span>getLayoutPath() . DIRECTORY_SEPARATOR . $layout;
        }

        </span><span>if</span> (pathinfo($file, PATHINFO_EXTENSION) !== <span>''</span><span>) {
            </span><span>return</span> $file;<span>//</span><span>如果布局文件有文件扩展名,返回文件</span>
<span>        }
        $path </span>= $file . <span>'</span><span>.</span><span>'</span> . $view->defaultExtension;<span>//</span><span>拼接默认的文件扩展名。</span>
        <span>if</span> ($view->defaultExtension !== <span>'</span><span>php</span><span>'</span> && !<span>is_file($path)) {
            $path </span>= $file . <span>'</span><span>.php</span><span>'</span>;<span>//</span><span>如果文件不存在,并且,默认的文件扩展名也不是php,则加上.php作为扩展名。</span>
<span>        }

        </span><span>return</span><span> $path;
    }</span>
로그인 후 복사

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1131876.htmlTechArticleyii2源码学习笔记(十二),yii2源码学习笔记 继续了解controller基类。 /* * * Runs a request specified in terms of a route.在路径中指定的请求。 * The r...
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
1 몇 달 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
1 몇 달 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
1 몇 달 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 채팅 명령 및 사용 방법
1 몇 달 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Symfony vs Yii2: 대규모 웹 애플리케이션 개발에 어떤 프레임워크가 더 좋나요? Symfony vs Yii2: 대규모 웹 애플리케이션 개발에 어떤 프레임워크가 더 좋나요? Jun 19, 2023 am 10:57 AM

웹 애플리케이션에 대한 수요가 계속 증가함에 따라 개발자는 개발 프레임워크를 선택할 때 점점 더 많은 선택권을 갖게 되었습니다. Symfony와 Yii2는 두 가지 인기 있는 PHP 프레임워크입니다. 둘 다 강력한 기능과 성능을 갖추고 있지만 대규모 웹 애플리케이션을 개발해야 하는 경우 어떤 프레임워크가 더 적합합니까? 다음으로 더 나은 선택을 하실 수 있도록 Symphony와 Yii2의 비교 분석을 진행하겠습니다. 기본 개요 Symphony는 PHP로 작성된 오픈 소스 웹 애플리케이션 프레임워크이며 다음을 기반으로 합니다.

PHP 프레임워크 Yii를 사용하여 고가용성 클라우드 백업 시스템을 개발하는 방법 PHP 프레임워크 Yii를 사용하여 고가용성 클라우드 백업 시스템을 개발하는 방법 Jun 27, 2023 am 09:04 AM

클라우드 컴퓨팅 기술이 지속적으로 발전하면서 데이터 백업은 모든 기업이 반드시 해야 할 일이 되었습니다. 이러한 맥락에서 가용성이 높은 클라우드 백업 시스템을 개발하는 것이 특히 중요합니다. PHP 프레임워크 Yii는 개발자가 고성능 웹 애플리케이션을 빠르게 구축하는 데 도움이 되는 강력한 프레임워크입니다. 다음은 Yii 프레임워크를 사용하여 고가용성 클라우드 백업 시스템을 개발하는 방법을 소개합니다. 데이터베이스 모델 설계 Yii 프레임워크에서 데이터베이스 모델은 매우 중요한 부분입니다. 데이터 백업 시스템에는 많은 테이블과 관계가 필요하기 때문에

Yii 프레임워크의 데이터 쿼리: 데이터에 효율적으로 액세스 Yii 프레임워크의 데이터 쿼리: 데이터에 효율적으로 액세스 Jun 21, 2023 am 11:22 AM

Yii 프레임워크는 웹 애플리케이션 개발 프로세스를 단순화하기 위한 다양한 도구와 구성 요소를 제공하는 오픈 소스 PHP 웹 애플리케이션 프레임워크입니다. 데이터 쿼리는 중요한 구성 요소 중 하나입니다. Yii 프레임워크에서는 SQL과 유사한 구문을 사용하여 데이터베이스에 액세스하여 데이터를 효율적으로 쿼리하고 조작할 수 있습니다. Yii 프레임워크의 쿼리 빌더에는 주로 ActiveRecord 쿼리, QueryBuilder 쿼리, 명령 쿼리 및 원본 SQL 쿼리 유형이 포함됩니다.

PHP에서 Yii3 프레임워크를 사용하는 방법은 무엇입니까? PHP에서 Yii3 프레임워크를 사용하는 방법은 무엇입니까? May 31, 2023 pm 10:42 PM

인터넷이 계속 발전함에 따라 웹 애플리케이션 개발에 대한 수요도 점점 높아지고 있습니다. 개발자의 경우 애플리케이션 개발에는 개발 효율성을 향상시킬 수 있는 안정적이고 효율적이며 강력한 프레임워크가 필요합니다. Yii는 풍부한 기능과 우수한 성능을 제공하는 선도적인 고성능 PHP 프레임워크입니다. Yii3은 Yii2를 기반으로 성능과 코드 품질을 더욱 최적화하는 Yii 프레임워크의 차세대 버전입니다. 이번 글에서는 Yii3 프레임워크를 사용하여 PHP 애플리케이션을 개발하는 방법을 소개하겠습니다.

Yii2 vs Phalcon: 그래픽 렌더링 애플리케이션 개발에 어떤 프레임워크가 더 좋나요? Yii2 vs Phalcon: 그래픽 렌더링 애플리케이션 개발에 어떤 프레임워크가 더 좋나요? Jun 19, 2023 am 08:09 AM

현재 정보화 시대에는 빅데이터, 인공지능, 클라우드 컴퓨팅 등의 기술이 주요 기업의 화두가 되었습니다. 이러한 기술들 중에서 고성능 그래픽 처리 기술로서 그래픽 카드 렌더링 기술이 점점 주목을 받고 있다. 그래픽 카드 렌더링 기술은 게임 개발, 영화 및 TV 특수 효과, 엔지니어링 모델링 및 기타 분야에서 널리 사용됩니다. 개발자에게 자신의 프로젝트에 적합한 프레임워크를 선택하는 것은 매우 중요한 결정입니다. 현재 언어 중에서 PHP는 Yii2, Ph와 같은 뛰어난 PHP 프레임워크 중 매우 역동적인 언어입니다.

Yii2 프로그래밍 가이드: Cron 서비스 실행 방법 Yii2 프로그래밍 가이드: Cron 서비스 실행 방법 Sep 01, 2023 pm 11:21 PM

"Yii가 무엇인가요?"라고 묻는다면 Yii의 이점을 검토하고 2014년 10월에 출시된 Yii 2.0의 새로운 기능을 간략하게 설명하는 이전 튜토리얼인 Yii 프레임워크 소개를 확인하세요. 흠> 이번 Yii2 프로그래밍 시리즈에서는 Yii2PHP 프레임워크를 사용하는 방법을 독자들에게 안내하겠습니다. 오늘 튜토리얼에서는 Yii의 콘솔 기능을 활용하여 크론 작업을 실행하는 방법을 공유하겠습니다. 과거에는 cron 작업에서 웹 액세스 가능 URL인 wget을 사용하여 백그라운드 작업을 실행했습니다. 이로 인해 보안 문제가 발생하고 일부 성능 문제가 발생합니다. Security for Startup 시리즈에서 위험을 완화하는 몇 가지 방법을 논의하는 동안 콘솔 기반 명령으로 전환하고 싶었습니다.

PHP 개발: Yii2 및 GrapeJS를 사용하여 백엔드 CMS 및 프런트엔드 시각적 편집 구현 PHP 개발: Yii2 및 GrapeJS를 사용하여 백엔드 CMS 및 프런트엔드 시각적 편집 구현 Jun 15, 2023 pm 11:48 PM

현대 소프트웨어 개발에서 강력한 콘텐츠 관리 시스템(CMS)을 구축하는 것은 쉬운 일이 아닙니다. 개발자는 광범위한 기술과 경험을 보유해야 할 뿐만 아니라 기능과 성능을 최적화하기 위해 가장 진보된 기술과 도구를 사용해야 합니다. 이 기사에서는 널리 사용되는 오픈 소스 소프트웨어인 Yii2와 GrapeJS를 사용하여 백엔드 CMS와 프런트엔드 시각적 편집을 구현하는 방법을 소개합니다. Yii2는 빠르게 구축할 수 있는 풍부한 도구와 구성 요소를 제공하는 인기 있는 PHPWeb 프레임워크입니다.

yii 객체를 배열로 변환하거나 json 형식으로 직접 출력하는 방법 yii 객체를 배열로 변환하거나 json 형식으로 직접 출력하는 방법 Jan 08, 2021 am 10:13 AM

Yii 프레임워크: 이 기사에서는 객체를 배열로 변환하거나 json 형식으로 직접 출력하는 Yii의 방법을 소개합니다. 이는 특정 참조 가치가 있으며 모든 사람에게 도움이 되기를 바랍니다.

See all articles