SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
Fási Gábor
@maerlyng
http://maerlyn.eu/

PHP függőségkezelés composerrel
Fási Gábor
Twitter @maerlyng   Blog maerlyn.eu
Csomagok és Függőségek
                          kezelése




Fási Gábor
Twitter @maerlyng                            Blog maerlyn.eu
A jelenlegi helyzet
                            PEAR
                            PECL




Fási Gábor
Twitter @maerlyng                         Blog maerlyn.eu
A jelenlegi helyzet




Fási Gábor
Twitter @maerlyng                         Blog maerlyn.eu
A composer birodalom
             Composer - CLI eszköz
                    egyszerű használat
                    projektenkénti függőségek
                    rugalmas és beépíthető




Fási Gábor
Twitter @maerlyng                               Blog maerlyn.eu
A composer birodalom
             Packagist - csomagtárhely
                    PHP libeket gyűjt
                    minden OS projektnek nyitva áll
                    VCS alapján dolgozik




Fási Gábor
Twitter @maerlyng                                     Blog maerlyn.eu
Használat
Egy composeres projekt használata
              git clone https://github.com/maerlyn/composer-demo

              Cloning into composer-demo...

              cd composer-demo/

              curl -s http://getcomposer.org/installer | php

              All settings correct for using Composer
              Composer successfully installed to: [...]/composer.phar
              Use it: php composer.phar




Fási Gábor
Twitter @maerlyng                                                       Blog maerlyn.eu
Egy composeres projekt használata
              php composer.phar install

              Installing from lock file
                - Package symfony/finder (dev-master)
                  Cloning b3adc8d5c29593db93c0abc4711a1e25fd3a6fa0

                    - Package symfony/routing (dev-master)
                      Cloning d3d9c02357b2db6503539d11f6c379ccd86f9cc4

                    - Package symfony/event-dispatcher (dev-master)
                      Cloning f6b7f60b0c29ab8167de7d7c9ba78fc9cc283c64

                    - Package monolog/monolog (1.0.2)
                      Downloading
                      Unpacking archive
                      Cleaning up
              Generating autoload files




Fási Gábor
Twitter @maerlyng                                                        Blog maerlyn.eu
Egy composeres projekt használata
               1 vendor/
               2   .composer/
               3   bin/
               4   monolog/
               5      monolog
               6   symfony/
               7      event-dispatcher/
               8      finder/
               9      routing/




Fási Gábor
Twitter @maerlyng                                                Blog maerlyn.eu
Projekt függőségek letöltése
             composer.json
                    a projekt gyökerében
                    függőségek leírása
               1 {
               2 "require": {
               3   "monolog/monolog": "1.0.2",
               4   "symfony/event-dispatcher": "dev-master",
               5   "symfony/finder": ">=2.0",
               6   "symfony/routing": "dev-master"
               7 }
               8 }




Fási Gábor
Twitter @maerlyng                                                 Blog maerlyn.eu
A verziókáosz elkerülése
             composer.lock
                    Csomagok verzióit is tartalmazza
                    Leváltja a composer.json-t
                    A composer install hozza létre
                    A composer update frissíti
                    Érdemes VCS-ben tartani

             Előnyök
                    A csapatban mindenki pontosan ugyanazzal a verzióval dolgozik
                    Deploy után minden gépen pontosan ugyanaz a verzió van
                    A felhasználók csak olyan verziót kapnak, amivel tesztelve van




Fási Gábor
Twitter @maerlyng                                                                    Blog maerlyn.eu
Autoload
             A libek megadják a névterüket:

               1 "autoload": {
               2 "psr-0": {"Monolog": "src/"}
               3 }

             A composer készít neked egy autoloadert:

               1 vendor/.composer/
               2   autoload_namespaces.php
               3   autoload.php
               4   ClassLoader.php
               5   installed.json

             Használat:

               1    require_once __DIR__ . "/../vendor/.composer/autoload.php";
               2
               3    use SymfonyComponentFinderFinder;
               4    use MonologLogger;
               5
               6    new Finder();
               7    new Logger("app");




Fási Gábor
Twitter @maerlyng                                                                 Blog maerlyn.eu
Tesztekben ugyanez
             A PHPUnit bootstrapjében:

               1 # tests/bootstrap.php
               2
               3 $loader = require_once __DIR__.'/../vendor/.composer/autoload.php';




Fási Gábor
Twitter @maerlyng                                                                      Blog maerlyn.eu
Alternatív tárhelyek
             01 "repositories": {
             02    "my-repo": {
             03       "composer": {
             04          "url": "http://example.org"
             05
             06       }
             07    },
             08    "MyRepo": {
             09       "vcs": {
             10          "url": "git://example.org/MyRepo.git"
             11       }
             12    },
             13    "example org": {
             14       "pear": {
             15          "url": "http://pear.example.org"
             16
             17       }
             18    },
             19    "packagist": false
             20 }

             Composer tárhelyek ($url/packages.json)
                    Packagist
                    Satis




Fási Gábor
Twitter @maerlyng                                                Blog maerlyn.eu
composer.json nélküli függőségek
             01     "repositories": {
             02        "some vendor repo": {
             03           "package": {
             04             "name": "vendor/package",
             05             "version": "1.0.0",
             06             "dist": {
             07                "url": "http://example.org/package.zip",
             08                "type": "zip"
             09
             10                  },
             11                  "source": {
             12                     "url": "git://example.org/package.git",
             13                     "type": "git",
             14                     "reference": "tag name, branch name or commit hash"
             15                  }
             16              }
             17          }
             18     },
             19
             20     "require": {
             21        "vendor/package": "1.0.0"
             22     }




Fási Gábor
Twitter @maerlyng                                                                         Blog maerlyn.eu
További információk
                    GetComposer.org
                    Packagist.org
                    github.com/composer
                    composer-dev google group
                    #composer & #composer-dev




Fási Gábor
Twitter @maerlyng                               Blog maerlyn.eu
Ω




Fási Gábor
Twitter @maerlyng       Blog maerlyn.eu

Contenu connexe

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

PHP függőségkezelés composerrrel

  • 3. Csomagok és Függőségek kezelése Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 4. A jelenlegi helyzet PEAR PECL Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 5. A jelenlegi helyzet Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 6. A composer birodalom Composer - CLI eszköz egyszerű használat projektenkénti függőségek rugalmas és beépíthető Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 7. A composer birodalom Packagist - csomagtárhely PHP libeket gyűjt minden OS projektnek nyitva áll VCS alapján dolgozik Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 9. Egy composeres projekt használata git clone https://github.com/maerlyn/composer-demo Cloning into composer-demo... cd composer-demo/ curl -s http://getcomposer.org/installer | php All settings correct for using Composer Composer successfully installed to: [...]/composer.phar Use it: php composer.phar Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 10. Egy composeres projekt használata php composer.phar install Installing from lock file - Package symfony/finder (dev-master) Cloning b3adc8d5c29593db93c0abc4711a1e25fd3a6fa0 - Package symfony/routing (dev-master) Cloning d3d9c02357b2db6503539d11f6c379ccd86f9cc4 - Package symfony/event-dispatcher (dev-master) Cloning f6b7f60b0c29ab8167de7d7c9ba78fc9cc283c64 - Package monolog/monolog (1.0.2) Downloading Unpacking archive Cleaning up Generating autoload files Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 11. Egy composeres projekt használata 1 vendor/ 2 .composer/ 3 bin/ 4 monolog/ 5 monolog 6 symfony/ 7 event-dispatcher/ 8 finder/ 9 routing/ Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 12. Projekt függőségek letöltése composer.json a projekt gyökerében függőségek leírása 1 { 2 "require": { 3 "monolog/monolog": "1.0.2", 4 "symfony/event-dispatcher": "dev-master", 5 "symfony/finder": ">=2.0", 6 "symfony/routing": "dev-master" 7 } 8 } Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 13. A verziókáosz elkerülése composer.lock Csomagok verzióit is tartalmazza Leváltja a composer.json-t A composer install hozza létre A composer update frissíti Érdemes VCS-ben tartani Előnyök A csapatban mindenki pontosan ugyanazzal a verzióval dolgozik Deploy után minden gépen pontosan ugyanaz a verzió van A felhasználók csak olyan verziót kapnak, amivel tesztelve van Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 14. Autoload A libek megadják a névterüket: 1 "autoload": { 2 "psr-0": {"Monolog": "src/"} 3 } A composer készít neked egy autoloadert: 1 vendor/.composer/ 2 autoload_namespaces.php 3 autoload.php 4 ClassLoader.php 5 installed.json Használat: 1 require_once __DIR__ . "/../vendor/.composer/autoload.php"; 2 3 use SymfonyComponentFinderFinder; 4 use MonologLogger; 5 6 new Finder(); 7 new Logger("app"); Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 15. Tesztekben ugyanez A PHPUnit bootstrapjében: 1 # tests/bootstrap.php 2 3 $loader = require_once __DIR__.'/../vendor/.composer/autoload.php'; Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 16. Alternatív tárhelyek 01 "repositories": { 02 "my-repo": { 03 "composer": { 04 "url": "http://example.org" 05 06 } 07 }, 08 "MyRepo": { 09 "vcs": { 10 "url": "git://example.org/MyRepo.git" 11 } 12 }, 13 "example org": { 14 "pear": { 15 "url": "http://pear.example.org" 16 17 } 18 }, 19 "packagist": false 20 } Composer tárhelyek ($url/packages.json) Packagist Satis Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 17. composer.json nélküli függőségek 01 "repositories": { 02 "some vendor repo": { 03 "package": { 04 "name": "vendor/package", 05 "version": "1.0.0", 06 "dist": { 07 "url": "http://example.org/package.zip", 08 "type": "zip" 09 10 }, 11 "source": { 12 "url": "git://example.org/package.git", 13 "type": "git", 14 "reference": "tag name, branch name or commit hash" 15 } 16 } 17 } 18 }, 19 20 "require": { 21 "vendor/package": "1.0.0" 22 } Fási Gábor Twitter @maerlyng Blog maerlyn.eu
  • 18. További információk GetComposer.org Packagist.org github.com/composer composer-dev google group #composer & #composer-dev Fási Gábor Twitter @maerlyng Blog maerlyn.eu