BOOTSTRAPPING YOUR OWN
PHP APP WITH COMPOSER
25 March 2014
Slide 2
Slide 2 text
WHY?
• Other frameworks seems too bloated for your
project.
• Need more visibility/transparency on how the app
is put together.
• Don’t like the default libraries provided by the
other frameworks & no easy way to
circumvent them.
Slide 3
Slide 3 text
COMPOSER
• Pick and choose libraries you want to put together
on Packagist (https://packagist.org/).
• Compose your own composer.json.
• Choose a package namespace for your own
project.
• Reference: https://getcomposer.org/
Slide 4
Slide 4 text
SAMPLE PROJECT
• Requirement:
• REST Server
• MySQL backend
• Logging.
!
!
• Consideration:
• No need for any
views.
• Simple CRUD app.
UNIT TESTS
• Tests folder
• bootstrap.php - Setup and server side includes.
• phpunit.xml - Config for running PHPUnit.
• *Test.php - The tests files.
Slide 9
Slide 9 text
TEST SPEC
• API Consumer should be able to:
• Get list of blog posts.
• Create a new blog post.
• Delete the blog post he created.
Slide 10
Slide 10 text
THE IMPLEMENTATION
• TDD: Red, Green, Refactor.
• Use your own namespace to take advantage of
Composer’s autoload mechanism.
• Don’t get ahead of yourself.