9. Composer
Activity 9.1: Implementing a Package to Generate a UUID
Solution
- Run the following command:
composer require ramsey/uuid
The output is as follows:
- List the packages in your vendor directory using the following command:
ls -lart vendor
The output is as follows:
- Edit
Example.php
to add ause ramsey/uuid/uuid
statement, and add a method similar toprintUuid()
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 }
- Edit your
index.php
file...