首页 文章

Laravel 5 Helper功能

提问于
浏览
1

有没有人知道源代码在内置的Laravel 5辅助函数中的位置,如view()和str_limit()?我很想知道他们是如何在后台做事的 .

1 回答

  • 1

    视图功能位于

    /vendor/laravel/framework/source/illuminate/Foundation/helpers.php
    

    第585行

    内容如下:

    if ( ! function_exists('view'))
    {
    /**
     * Get the evaluated view contents for the given view.
     *
     * @param  string  $view
     * @param  array   $data
     * @param  array   $mergeData
     * @return \Illuminate\View\View
     */
    function view($view = null, $data = array(), $mergeData = array())
    {
        $factory = app('Illuminate\Contracts\View\Factory');
    
        if (func_num_args() === 0)
        {
            return $factory;
        }
    
        return $factory->make($view, $data, $mergeData);
    }
    }
    

    开始使用像Php storm这样的IDE,只需单击一下即可找到所有这些功能

相关问题