我想开发laravel包我用一个类在github上创建了一个示例项目。我在require{}
数组中的项目composer.json
中使用github php包composer.json
中的包名称。
当我做composer update
时,我会出错。我需要使用Github和composer来开发和集成PHP/Laravel包的说明性步骤。
我正在将包添加到的项目的Composer.json是:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"jeroen-g/laravel-packager": "^1.3",
"igaster/laravel-theme": "^1.1",
"laura/cms": "*.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r "copy('.env.example', '.env');""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
},
"repositories": [{
"type": "vcs",
"url": "https://github.com/harish-php/lauracms"
}]
}
编辑
添加了更多关于如何创建自定义包的解释
自定义包composer.json
{
"name": “packageName”,
"autoload": {
"psr-4": {
“MySourcesNamespace\”: "srcDir”
}
}
}
应用程序之子
"require": {
"packageName": "1.0.*"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/…"
}
]
应该标记此处的版本。如果你没有标签,你可以依赖主分支:
"require": {
"MySourcesNamespace\": "dev-master"
},
在进行composer更新时,类应该在供应商目录中。