2017-09-20 64 views
1

我已经创建了自定义的基本Laravel包,我已经将它上传到我的github帐户,并且还将github回购连接到https://packagist.org安装定制laravel包

我的资料库网址为https://github.com/johnsmithamk/message.git

我想我的本地服务器上安装从GitHub新Laravel应用程序包。

我正在使用Laravel verson 5.5。下面是我composer.json代码

Composer.json

{ 

"name": "johnsmithamk/message", 

"description": "Sample Package in Vendor folder", 
"type": "project", 
"license": "0.1", 
"authors": [ 
    { 
     "name": "John Smith", 
     "email": "[email protected]" 
    } 
], 
"minimum-stability": "dev", 

"require": { 
    "Illuminate/support": "~5" 
}, 

"autoload":{ 
    "psr-4":{ 
     "test\\message\\": "vendor/test/message/src/" 
    } 
}, 

"extra": { 
    "laravel": { 
     "providers": [ 
      "test\\message\\MessageServiceProvider" 
     ] 
    } 
} 

}

添加存储库Packagist它告诉使用这个命令来安装包后:

composer create-project johnsmithamk/message

但运行上面的命令后,我越来越以下错误:

[InvalidArgumentException]           
    Could not find package johnsmithamk/message with stability stable. 


create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>] 

任何人都可以就如何从GitHub安装laravel包建议?

请检查composer.json的代码,让我知道我是否犯了一些错误。

+0

你的意思是'作曲家要求......'? –

+0

我试图通过这两种方法 - >作曲家需要johnsmithamk /消息和 - >作曲家创建项目johnsmithamk /消息 但没有工作 – John

回答

1

您需要使用的

composer require johnsmithamk/message

代替

composer create-project johnsmithamk/message

我已经测试你的存储库安装到我的项目,它没有显示任何你所提到的问题。

require将软件包包含到您已有的项目中,并且create-project按照说明创建一个新项目。

你可以有自己的差异一看:

https://stackoverflow.com/a/22944572/3887342

编辑:

增加了你的包到项目,并得到了一些错误,但认为是由于您的一些代码在你composer.json像:

1.需要从composer.json中删除此vcs类型,因为我们将使用packagist。

"repositories": [ 
     { 
      "type": "vcs", 
      "url": "https://github.com/johnsmithamk/message.git" 
     } 
    ], 

对一些流行的包的composer.json

https://github.com/cartalyst/sentinel/blob/2.0/composer.json

2.采用开发,而不是掌握分支一看作为有可能是唯一的Dev分支,现在却需要在看看这个。

"minimum-stability": "dev", 

https://github.com/LaravelCollective/html/blob/5.5/composer.json#L52

我的日志不显示任何错误。

C:\xampp\htdocs\Platform>composer require johnsmithamk/message 

Using version dev-master for johnsmithamk/message 
./composer.json has been updated 
Loading composer repositories with package information 
Updating dependencies (including require-dev) 
Package operations: 1 install, 0 updates, 0 removals 
    - Installing johnsmithamk/message (dev-master 319a00d): Cloning 319a00d01b 
    Failed to download johnsmithamk/message from source: Failed to clone https://github.com/johnsmithamk/message.git, git was not found, check that it i 
s installed and in your PATH env. 

'git' is not recognized as an internal or external command, 
operable program or batch file. 

    Now trying to download from dist 
    - Installing johnsmithamk/message (dev-master 319a00d): Downloading (100%) 
Writing lock file 
Generating autoload files 
> Illuminate\Foundation\ComposerScripts::postUpdate 
> php artisan optimize 

Generating optimized class loader 
The compiled services file has been removed. 
+0

我试图通过这两种方法,但得到 – John

+0

做到了正确安装到您的laravel同样的错误项目..? 你可以建议我使用什么方法吗....? – John

+0

我正在安装软件包,但尚未完成。但它没有显示你提到的问题 – PaladiN