PHP

Prerequisites

    Install CLI​
    PHP 7.3 or greater
    composer installed
    composer install already run on the project

Command-line

Run the following command line by setting your parameters.
1
cdefense scan --lang=php --api-key=<YOUR_API_KEY> \
2
--path=/d/temp/php-helloworld-app --project-name="my-php-project"
Copied!

Gitlab Integration

1
image: "php:7.3"
2
​
3
before_script:
4
# Install composer
5
- apt-get update
6
- apt-get install zip unzip
7
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
8
- php composer-setup.php
9
- php -r "unlink('composer-setup.php');"
10
- php composer.phar install
11
​
12
stages:
13
- Test
14
​
15
run_scan:
16
stage: Test
17
script:
18
- composer install
19
- curl https://raw.githubusercontent.com/CloudDefenseAI/cd/master/latest/cd-latest-linux-x64.tar.gz > /tmp/cd-latest-linux-x64.tar.gz && tar -C /usr/local/bin -xzf /tmp/cd-latest-linux-x64.tar.gz && chmod +x /usr/local/bin/cdefense
20
- cdefense scan --lang=php --project-name=php-sample-project --api-key=$API_KEY --path=. --verbose
21
- echo $?
22
​
Copied!
Last modified 1mo ago