SlideShare une entreprise Scribd logo
1  sur  7
Télécharger pour lire hors ligne
Gestionnaire de dépendances pour PHP

BOUSSARHANE Mehdi
Analyste/développeur & chargé d’analyse de données
Composer un outil de gestion de dépendances pour PHP

L’idée derrière composer est d’installer l’environnement de travail de manière
rapide et sécurisée. L’outil va vous permettre de télécharger les librairies dont
votre projet a besoin et prendra en charge la gestion des dépendances.

Composer est un gestionnaire de dépendances très inspiré de celui que vous
pouvez trouver avec node.js (npm) ou même PEAR ( à la différence que celuici vous permet d’installer une dépendance au niveau du projet et pas
globalement).

2
Comment Composer sait où trouver les bibliothèques ?

Pour fonctionner, composer a besoin d'aller chercher les librairies dans un
dépôt: Packegist (l’annuaire que Composer utilise par défaut afin de lister,
rechercher et installer les bibliothèques).

Comment ca marche ?
1.

2.
3.

On définit dans un fichier la liste des bibliothèques dont le projet dépend,
ainsi que leur version ;
On exécute une commande pour installer ou mettre à jour ces bibliothèques
(et leurs propres dépendances donc) ;
On inclut alors le fichier d'autoload généré par Composer dans notre projet.

3
Installer Composer

Il suffit de télécharger et installer Composer-Setup.exe, qui aura tout de même
besoin d’un moteur PHP pour parvenir à ses fins (par exemple celui de Wamp
c:wampbinphpphpx.x.xphp.exe). Fermez toutes les invites de commandes
ouvertes, lancez-en une nouvelle et saisissez composer about pour vérifier que
l’installation s’est bien déroulée. Si cela n’est pas le cas, essayez de l’installer à la
main.

Pour les environnements Mac/Linux, c’est presque la même procédure et selon
que vous voulez l’installer et créer le raccourci avec cette commande :
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
4
Utilisation
Au préalable, vous devez avoir un fichier composer.json contenant la
configuration des dépendances à la racine de votre projet.
Il se présente comme ceci :

Pour l’installation :
vous avez la possibilité de mettre à jour un ou plusieurs paquets.
ou pour une librairie en particulier :
5
Conclusion
Et voilà le tour est joué ! les
fichiers
sont
téléchargés
directement au bon endroit.
Plus besoin de parcourir tous
les dépôts et de télécharger les
archives sur votre machine, de
décompresser et d’uploader les
fichiers sur votre serveur de
dev. Vous pouvez construire
votre environnement de travail
en très peu de temps, tout en
garantissant l’intégrité de vos
dépendances.
6
Questions

Contenu connexe

En vedette

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
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

En vedette (20)

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...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Composer – Un gestionnaire de dépendances pour vos projets PHP

  • 1. Gestionnaire de dépendances pour PHP BOUSSARHANE Mehdi Analyste/développeur & chargé d’analyse de données
  • 2. Composer un outil de gestion de dépendances pour PHP L’idée derrière composer est d’installer l’environnement de travail de manière rapide et sécurisée. L’outil va vous permettre de télécharger les librairies dont votre projet a besoin et prendra en charge la gestion des dépendances. Composer est un gestionnaire de dépendances très inspiré de celui que vous pouvez trouver avec node.js (npm) ou même PEAR ( à la différence que celuici vous permet d’installer une dépendance au niveau du projet et pas globalement). 2
  • 3. Comment Composer sait où trouver les bibliothèques ? Pour fonctionner, composer a besoin d'aller chercher les librairies dans un dépôt: Packegist (l’annuaire que Composer utilise par défaut afin de lister, rechercher et installer les bibliothèques). Comment ca marche ? 1. 2. 3. On définit dans un fichier la liste des bibliothèques dont le projet dépend, ainsi que leur version ; On exécute une commande pour installer ou mettre à jour ces bibliothèques (et leurs propres dépendances donc) ; On inclut alors le fichier d'autoload généré par Composer dans notre projet. 3
  • 4. Installer Composer Il suffit de télécharger et installer Composer-Setup.exe, qui aura tout de même besoin d’un moteur PHP pour parvenir à ses fins (par exemple celui de Wamp c:wampbinphpphpx.x.xphp.exe). Fermez toutes les invites de commandes ouvertes, lancez-en une nouvelle et saisissez composer about pour vérifier que l’installation s’est bien déroulée. Si cela n’est pas le cas, essayez de l’installer à la main. Pour les environnements Mac/Linux, c’est presque la même procédure et selon que vous voulez l’installer et créer le raccourci avec cette commande : $ curl -sS https://getcomposer.org/installer | php $ mv composer.phar /usr/local/bin/composer 4
  • 5. Utilisation Au préalable, vous devez avoir un fichier composer.json contenant la configuration des dépendances à la racine de votre projet. Il se présente comme ceci : Pour l’installation : vous avez la possibilité de mettre à jour un ou plusieurs paquets. ou pour une librairie en particulier : 5
  • 6. Conclusion Et voilà le tour est joué ! les fichiers sont téléchargés directement au bon endroit. Plus besoin de parcourir tous les dépôts et de télécharger les archives sur votre machine, de décompresser et d’uploader les fichiers sur votre serveur de dev. Vous pouvez construire votre environnement de travail en très peu de temps, tout en garantissant l’intégrité de vos dépendances. 6