2017-09-20 52 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