Load a Github Gist with Composer
source link: https://donatstudios.com/Load-Gist-With-Composer
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Load a Github Gist with Composer
Composer is amazing for pulling in packages, but what if you find a Gist that isn't Composer aware? Fear not, as Composer has the magical ability to pull in repositories not explicitly set up in Packagist by defining them in the "repositories" section.
But what if you wanted to load a single class from a git gist?
You can add the following repositories
section to your composer.json
file, adjusting name
and url
as necessary. The name
should be a vendor/package
(all lower) style name you make up for it, and url
will be from the Clone this gist box on GitHub.
"repositories": [
{
"type":"package",
"package": {
"name": "turin86/wssoapclient",
"version": "master",
"source": {
"url": "https://gist.github.com/5569152.git",
"type": "git",
"reference":"master"
},
"autoload": {
"classmap": ["."]
}
}
}
]
Then in your require section, add your selected name
as follows.
"require": {
"turin86/wssoapclient": "dev-master"
}
If the name of the class doesn't match the filename in a friendly autoload-able manner, you'll have to replace "classmap": ["."]
with "files": ["ClassToAutoload.php"]
replacing ClassToAutoload.php
with the filename. More info on autoloading can be found here. Note that if you are experimenting with autoload settings you may need to remove your vendor directory and composer install
, as updates to the autoload were not reflected for me after a composer update
.
After this, just run composer update
and voilà, you are loading a gist with Composer.
Comment by: Fendi Septiawan on Oct. 11, 2017
Recommend
-
95
README.md Gist.vim This is a vimscript for creating gists (http://gist.github.com). For the latest version please see
-
12
Welcome to gist.github.com/username Jan 17, 2020 I'd love to tell you that I figured this one out on my own but I di...
-
5
gist:19b2ef7206922df5d455c1280dc7e8b7 · GitHub Instantly share code, notes, and snippets. #include <stdio.h> static unsigned f(uns...
-
4
Sublime Text Sublime Text 2 + Gist = 代码片段管理器 ...
-
6
安装gist库 (package-install-new 'gist) gist-list 在新buffer中显示gist。 第一次使用时需要输入github的用户名和密码。 在显示gist的buffer中...
-
2
Gist一直可用 哎哎4年前 (2017-02-21)C++670 【翻译来源】:
-
10
Gist.vim This is a vimscript for creating gists (http://gist.github.com). For the latest version please see https://github.com/mattn/vim-gist
-
2
This is a caption for my Gist · GitHub Instantly share code, notes, and snippets. let ctx = CassandraCtx { session, insert_stmt }; let ctx = web::D...
-
6
用 PostgreSQL 的 int4range 與 GiST 發現自己根本還不熟悉 PostgreSQL 的特性,寫一下記錄起來。 產品上常常會有 coupon 與 voucher 之類的設計,這時候通常都會設定 coupon 或 voucher 的有...
-
3
TryCF Gist · GitHub Instantly share code, notes, and snippets. TryCF Gist <cfscript>...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK