• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

cviebrock/laravel5-package-template: Boilerplate template for Laravel 5 packages

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

cviebrock/laravel5-package-template

开源软件地址(OpenSource Url):

https://github.com/cviebrock/laravel5-package-template

开源编程语言(OpenSource Language):

PHP 100.0%

开源软件介绍(OpenSource Introduction):

Boilerplate Laravel 5 Package

Installation

Clone this repo with minimal history:

git clone --depth 1 [email protected]:cviebrock/laravel5-package-template.git

Rename the directory and re-init it as your own package:

mv laravel5-package-template my-package
cd my-package
rm -rf .git
git init

Configuration

The boilerplate files provide a scaffold for building your own package. You'll need to make a bunch of changes to the files we've provided to make it your own.

composer.json

Edit composer.json to reflect your package information. At a minimum, you will need to change the package name and autoload lines so that "vendor/package" reflects your new package's name and namespace.

{
    "name": "vendor/package",
    ...
    "autoload": {
        "psr-4": {
            "Vendor\\Package\\": "src/"
        }
    },
    ...
},

config/packagename.php

Rename config/packagename.php to something more useful, like config/my-package.php. This is the configuration file that Laravel will publish into it's config directory. Laravel 5 doesn't use the config/packages/vendor/... structure that Laravel 4 did, so pick a file name that's not likely to conflict with existing configuration files.

src/ServiceProvider.php

Open up src/ServiceProvider.php as well. At a minimum you'll need to change the namespace at the top of the file (it needs to match the PSR-4 namespace you set in composer.json).

In the boot() method, comment out or uncomment the components your package will need. For example, if your package only has a configuration, then you can comment out everything except the handleConfigs() call:

public function boot() {
    $this->handleConfigs();
    // $this->handleMigrations();
    // $this->handleViews();
    // $this->handleTranslations();
    // $this->handleRoutes();
}

In the handleConfigs() method, you'll want to change the "packagename" references to the name you chose up above (in the [config/packagename.php] instructions).

For the other methods, again change instances of "vendor" and "packagename" to your package's name.

Last Steps

Update the LICENSE file as required (make sure it matches what you said your package's license is in composer.json).

Finally, edit this README.md file and replace it with a description of your own, awesome Laravel 5 package.

Commit everything to your (newly initialized) git repo, and push it wherever you'll keep your package (Github, etc.).

Enjoy coding!




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap