Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Create your own composer package
Search
Lattapon Yodsuwan
December 16, 2015
Programming
1
88
Create your own composer package
Gentle introduction to php package to use with composer
Lattapon Yodsuwan
December 16, 2015
Tweet
Share
Other Decks in Programming
See All in Programming
CSC307 Lecture 06
javiergs
PRO
0
690
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
190
AIによる開発の民主化を支える コンテキスト管理のこれまでとこれから
mulyu
3
740
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
7
900
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
390
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
470
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
6.1k
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
140
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
290
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
180
ノイジーネイバー問題を解決する 公平なキューイング
occhi
0
110
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
77
5.3k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
740
Paper Plane
katiecoart
PRO
0
46k
Design in an AI World
tapps
0
150
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
650
RailsConf 2023
tenderlove
30
1.3k
30 Presentation Tips
portentint
PRO
1
230
Paper Plane (Part 1)
katiecoart
PRO
0
4.4k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
230
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
310
Transcript
Create your own composer package
Why • Easy to manage dependencies • Easy to use
with 3rd party library
normally `require` <?php require_once ‘pantip/pantip.class.php’; require_once ‘twitter/twitter.class.php’; require_once ‘facebook/facebook.class.php’; require_once
‘instagram/instagram.class.php’;
the composer way <?php require_once ‘vendor/autoload.php’;
Create Package $ composer init // composer.json { "name": “clozed2u/hello-composer",
"authors": [ { "name": "Lattapon Yodsuwan", "email": "
[email protected]
" } ], "require": {} }
Directory Structure hello-composer | |__src | |__Hello.php | |__tests |
|__HelloTest.php | |__composer.json | |__optional(circle.yml, .travis.yml, phpunit.xml)
Hello class <?php namespace Hello; class Hello { public function
sayAnything($message) { return $message; } }
Hello Tests <?php use \Hello\Hello; class HelloTest extends PHPUnit_Framework_TestCase {
public function testSayAnything() { $said = new Hello(); $this->assertEquals( "X JAPAN ROCK!!”, $said->sayAnything("X JAPAN ROCK!!”) ); } }
Add autoload to composer // composer.json { …, "require-dev": {
"phpunit/phpunit": "*" }, "autoload": { "psr-4": {"Hello\\": "src/"} } }
Push to git and release
Use package $ composer install // composer.json { "repositories": [
{ "type": "vcs", "url": "https://github.com/clozed2u/hello-composer.git" } ], "require": { "clozed2u/hello-composer": "1.0.0" } }
Push to packagist.org $ composer require clozed2u/hello-composer
Don’t forget continuous integration
/clozed2u/hello-composer
Me Name: Lattapon Yodsuwan Github/Twitter: @clozed2u Email:
[email protected]
We are hiring