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...