Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The PHP Workshop

You're reading from   The PHP Workshop Learn to build interactive applications and kickstart your career as a web developer

Arrow left icon
Product type Paperback
Published in Oct 2019
Publisher Packt
ISBN-13 9781838648916
Length 604 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (8):
Arrow left icon
Markus Gray Markus Gray
Author Profile Icon Markus Gray
Markus Gray
David Carr David Carr
Author Profile Icon David Carr
David Carr
Bart McLeod Bart McLeod
Author Profile Icon Bart McLeod
Bart McLeod
Mark McCollum Mark McCollum
Author Profile Icon Mark McCollum
Mark McCollum
Alexandru Busuioc Alexandru Busuioc
Author Profile Icon Alexandru Busuioc
Alexandru Busuioc
Jordi Martinez Jordi Martinez
Author Profile Icon Jordi Martinez
Jordi Martinez
M A Hossain Tonu M A Hossain Tonu
Author Profile Icon M A Hossain Tonu
M A Hossain Tonu
Vijay Joshi Vijay Joshi
Author Profile Icon Vijay Joshi
Vijay Joshi
+4 more Show less
Arrow right icon
View More author details
Toc

9. Composer

Activity 9.1: Implementing a Package to Generate a UUID

Solution

  1. Run the following command:
    composer require ramsey/uuid

    The output is as follows:

    Figure 9.17: Requiring the packages

  2. List the packages in your vendor directory using the following command:
    ls -lart vendor

    The output is as follows:

    Figure 9.18: Listing the packages

  3. Edit Example.php to add a use ramsey/uuid/uuid statement, and add a method similar to printUuid() as follows:

    Example.php

    1  <?php
    2 
    3  namespace Packt;
    4 
    5  use Monolog\Logger;
    6  use Ramsey\Uuid\Uuid;
    7 
    8  class Example
    9  {
    10     protected $logger;
    11     public function __construct(Logger $logger)
    12     {
    13         $this->logger = $logger;
    14     }
  4. Edit your index.php file...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime