Published on

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. Composing PHP projectsA new PHP package manager Nils Adermann @naderman September 10th 2011
  2. 2. NIH (Not Invented Here)Wikipedias list of template engines: 33 PHP 15 Python 3 RubyLists of >100 PHP engines on the webWhy is PHP at the top?
  3. 3. Symfony2 PackagesLibraries / ComponentsBundlesPSR-0 AutoloadingEveryone is using Git(hub)
  4. 4. phpBB PackagesphpBB3 MODX Extensions (>= 3.1)phpBB4 Regular Symfony2 Bundles “ ExtensionBundles”
  5. 5. Packages for End-UsersWeb UI browsing, installing, removing, updating changes made in copy of vendor directory A) overwrite old directory after update B) download & upload vendor directory C) (S)FTP support
  6. 6. Packages for developersConsistent versions across dev machinesProject specific package versionsEasy definition of dependencies in a fileAbility to work on dependencies codeSimple definition of own packages
  7. 7. PEAR / PEAR2 / PyrusMost people still use PHP4 PEARPEAR2 requires PHP 5.3 uses namespacesPyrus is the PEAR2 Installer phar archive per-project package repositories
  8. 8. Problems Pyrus does not solveConsistent versions across machinesWeb UI with vendor directory hardcoded output, paths directory transactions prevent self-updateWorking on dependencies codeNon-PHP dependencies
  9. 9. Channels in PEARPEAR requires explicit channelsChannels cannot replace foreign packageYou need to know channel locations
  10. 10. ComposerSimple JSON declaration of packagescomposer.lock fileVirtual PackagesDependency Resolution with SAT
  11. 11. Composer RepositoriesAnything Git Repository, tar.gz, Local directory, ...Restriction to repository of approvedpackages possibleRepositories can provide same packages Prefered Repositories
  12. 12. Packagisthttp://packagist.orgCentral repository of packagesAll kinds of packages allowed Libraries Framework Bundles/Plugins/whatever Application Plugins (e.g. Drupal/Wordpress)
  13. 13. SAT?Boolean Satisfiability Problem: Can (A|B)&(C|D|(E&(A|D))&E be true?D(isjunctive)NF: (A&B)|(C&D&A)|(B&D)|CC(onjunctive)NF: (A|B)&(C|D|A)&(B|D)&C
  14. 14. NP?“ hard” problemspolynomial: n, n^2, n^3, 5n^4 + 2n^2 ... 100^2 = 10,000 100^3 = 1,000,000exponential: 2^n, 100^n, 100^5n, ... 2^100 ~= 1,267,650,600,000,000,000,000,000,000,000
  15. 15. NP?“ nondeterministic polynomial time” no known polynomial time algorithm which: - can solve all instances of the problem - does not need to try all combinationsSAT is NP-complete (Cooks theorem)
  16. 16. Package ManagementPoolRepositoriesPackage Name & Version requires, conflicts, provides
  17. 17. Dependency ResolutionUser wants to:- install some packages- update some packages- remove some packages- keep some packages
  18. 18. Dependency ResolutionEDOS Project Workpackage 2 Team. Report on formal management of software dependencies. EDOSProject Deliverable Work Package 2, Deliverable 2, March 2006.
  19. 19. Dependency ResolutionIdeal:
  20. 20. Dependency ResolutionAcceptable:
  21. 21. Dependency ResolutionNo solution: APT PortagePoor solution: smart Urpmi
  22. 22. Dependency Resolution with SAT SUSEs libzypper (Michael Schroeder) Goals: Fast Complete & Reliable Understandable messages & explanations Based on ideas from minisat
  23. 23. Rule GenerationJob Rules: Install A: (A) Remove A: (-A)
  24. 24. Rule GenerationDependency Rules: A requires B: (-A|B1|B2) A conflicts with B: (-A|-B1), (-A|-B2) C and D provide A: A requires C or DPolicy Rules: B1 can be updated to B2: (B1|B2) B2 obsoletes B1: (-B1|-B2)
  25. 25. Solving RulesUnit Propagation: (A|B|C), (-C), (-A|C) (-C) C: false (-A|C) A: false (-A: true) (A|B|C) B: true
  26. 26. Rule Solving AlgorithmUnit Propagation Contradiction? Add Rule -X or unsolvable Backtrack to previous assignmentAssign undecided variable X (free choice)Repeat until solved
  27. 27. Free ChoicesKeep installed packages installedDo not install unecessary packagesPick newest version
  28. 28. Composer Demo
  29. 29. Resources group ...
  30. 30. Thank you! and Michael Schröder at Novell for his slides Questions?