|
| 1 | +# Semaphore demo CI/CD pipeline using PHP Laravel |
| 2 | + |
| 3 | +Example application and CI/CD pipeline showing how to run a PHP Laravel project |
| 4 | +on Semaphore 2.0. |
| 5 | + |
| 6 | +## Local project setup |
| 7 | + |
| 8 | +To setup the project locally, your local environment needs to meet common |
| 9 | +Laravel development requirements, as per [Laravel |
| 10 | +Documentation](https://laravel.com/docs/5.7#server-requirements). |
| 11 | +We recommend setting up using Vagrant and Homestead, as it is a turn key |
| 12 | +solution supported on all major operating systems. |
| 13 | + |
| 14 | +Once the local environment is set up, you can run the following commands: |
| 15 | + |
| 16 | +``` |
| 17 | +cp .env.example .env // and enter your DB details in the newly created .env |
| 18 | +composer install |
| 19 | +php artisan key:generate |
| 20 | +php artisan migrate |
| 21 | +``` |
| 22 | + |
| 23 | +## CI/CD on Semaphore |
| 24 | + |
| 25 | +Fork this repository and use it to [create a |
| 26 | +project](https://docs.semaphoreci.com/article/63-your-first-project): |
| 27 | + |
| 28 | +``` |
| 29 | +curl https://storage.googleapis.com/sem-cli-releases/get.sh | bash |
| 30 | +sem connect <semaphore-organization-link> <semaphore-id> // found in Semaphore Dashboard |
| 31 | +cd <project directory> |
| 32 | +sem init |
| 33 | +``` |
| 34 | + |
| 35 | +After that, push to the repository to trigger a workflow on Semaphore. |
| 36 | + |
| 37 | +The CI pipeline will look like this: |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +The example pipeline contains 6 blocks: |
| 42 | + |
| 43 | + - Install Dependencies |
| 44 | + - installs and caches all composer and npm dependencies |
| 45 | + - Run Code Analysis |
| 46 | + - Runs PHP Mess Detector which as an example is installed as a composer dependency |
| 47 | + - Runs PHP Code Sniffer which as an example is installed as a composer dependency |
| 48 | + - Runs PHP Copy Detector which is called via cURL from the .phar package available online |
| 49 | + - Run Unit Tests |
| 50 | + - Runs PHPUnit Unit Tests |
| 51 | + - Run Browser Tests |
| 52 | + - Runs browser tests through Laravel Dusk. |
| 53 | + - Run Security Tests |
| 54 | + - Runs Sensiolabs security checker pulled in via cURL |
| 55 | + |
| 56 | +## License |
| 57 | + |
| 58 | +Copyright (c) 2019 Rendered Text |
| 59 | + |
| 60 | +Distributed under the MIT License. See the file LICENSE.md. |
0 commit comments