Laravel 4中的模块

时间:2013-06-06 13:55:06

标签: php laravel laravel-4

在L3中我设法建立了一个模块系统,我可以从管理区域安装/卸载模块。

if(!Bundle::exists($name))
    {
        // Load the bundle
        // If a routes file exists then we'll assume it handles routes of it's own name.
        // Remember, if you need it to handle a custom route you should manually add
        // the bundle in application/bundles.php.
        Bundle::register($name, array(
                'handles'   => File::exists($path.DS.'routes.php') ? $name : null,
                'location'  => 'path: '.$path,
                'auto'      => true)
        );

        // autobundle is already in the loop that's starting bundles so we
        // can't let the normal mechanism start it. We'll start it here.
        Bundle::start($name);
    }

我怎么能在L4中做到这一点? L4对我来说看起来很不一样,我2个月前开始使用L3(第一个框架)

2 个答案:

答案 0 :(得分:4)

或者,如果您仍然需要更具针对性的模块,可以查看我的教程:http://creolab.hr/2013/05/modules-in-laravel-4/

我将很快扩展该文章,解释如何构建一个简单的界面来激活/停用这些模块。

答案 1 :(得分:0)

Bundles现在是Packages,它实际上是存储在不同位置并由Packagist索引的可重用PHP代码库(可以Composer安装)。

为了进行基于Laravel的软件包开发,您需要查看此文档:http://laravel.com/docs/packages这应该可以帮助您。