@danaluther
How to analyze your codebase
with Exakat using Docker
Static analysis for everyone
https://joind.in/talk/b32c9
@danaluther
Static Analysis
What is it and why do we need it?
@danaluther
Static Analysis
What is it and why do we need it?
• Dynamic Analysis - Performed while the program is running
@danaluther
Static Analysis
What is it and why do we need it?
• Dynamic Analysis - Performed while the program is running
• Unit / Functional / Acceptance Tests
@danaluther
Static Analysis
What is it and why do we need it?
• Dynamic Analysis - Performed while the program is running
• Unit / Functional / Acceptance Tests
• Static Analysis - Performed before running the program
@danaluther
Static Analysis
What is it and why do we need it?
• Dynamic Analysis - Performed while the program is running
• Unit / Functional / Acceptance Tests
• Static Analysis - Performed before running the program
• Analyze as part of the development cycle before unit tests are run
@danaluther
Static Analysis
What is it and why do we need it?
• Dynamic Analysis - Performed while the program is running
• Unit / Functional / Acceptance Tests
• Static Analysis - Performed before running the program
• Analyze as part of the development cycle before unit tests are run
• Can catch errors and vulnerabilities that may be overlooked by Unit Tests
@danaluther
Static Analysis
What is it and why do we need it?
• Dynamic Analysis - Performed while the program is running
• Unit / Functional / Acceptance Tests
• Static Analysis - Performed before running the program
• Analyze as part of the development cycle before unit tests are run
• Can catch errors and vulnerabilities that may be overlooked by Unit Tests
• Identify patterns in the code
@danaluther
Popular Options for Static Analysis
Standalone and Integrated Options
• Exakat - https://www.exakat.io/en/

• PHPStan - https://phpstan.org/

• Psalm - https://psalm.dev/

• PHP_CodeSni
ff
er - https://github.com/squizlabs/PHP_CodeSni
ff
er

• PhpStorm Inspections - https://www.jetbrains.com/help/phpstorm/code-
inspection.html
@danaluther
@danaluther
Take it with a grain of salt…
function ex_mysql_unbuffered_query($query, $dbh)


{


if (!$this
-
>
use_mysqli)


{


	
return mysql_unbuffered_query($query, $dbh);


	
}


return mysqli_query($dbh, $query, MYSQLI_USE_RESULT);


}
@danaluther
Why Exakat?
Community version with multiple report options
https://github.com/exakat/exakat
@danaluther
Why Exakat?
Community version with multiple report options
• Analyze once, generate multiple reports
https://github.com/exakat/exakat
@danaluther
Why Exakat?
Community version with multiple report options
• Analyze once, generate multiple reports
• Multiple PHP version compatibility reports
https://github.com/exakat/exakat
@danaluther
Why Exakat?
Community version with multiple report options
• Analyze once, generate multiple reports
• Multiple PHP version compatibility reports
• Option for visual representation of the analysis
https://github.com/exakat/exakat
@danaluther
Why Exakat?
Community version with multiple report options
• Analyze once, generate multiple reports
• Multiple PHP version compatibility reports
• Option for visual representation of the analysis
• Option for customized reports
https://github.com/exakat/exakat
@danaluther
Damien Seguy
@faguo
• https://www.exakat.io/en/bonjour/

• All the elePHPants
@danaluther
Why Docker?
No additional local code installation required!
• Exakat o
ffi
cial image requires no lengthy local install.

• Exakat public repo allows for quickly generating the latest versions.
@danaluther
Get the Exakat Docker image
https://hub.docker.com/r/exakat/exakat
> docker image pull exakat/exakat
@danaluther
Confirm the docker container runs
> docker container run
-
-
rm exakat/exakat exakat version
@danaluther
Confirm the configuration options
> docker container run
-
-
rm exakat/exakat exakat doctor
@danaluther
Time to Analyze!
https://github.com/DanaLuther/yii2-swivel
@danaluther
Create Project Report Docker Volume
Create the local directory that you want to store your project
fi
les in
> mkdir
-
p /Users/danaluther/Repos/exakat_y2s
@danaluther
Create Project Report Docker Volume
Create a docker volume that points to the directory which was just created
> docker volume create exakat_y2s 


-
-
opt type=none
-
-
opt o=bind 


-
-
opt device=/Users/danaluther/Repos/exakat_y2s
@danaluther
Create Project Report Docker Volume
Con
fi
rm the volume was created properly
> docker volume inspect exakat_y2s
@danaluther
Customize exakat ini
https://exakat.readthedocs.io/en/latest/User/Con
fi
guration.html
• Command line options

• The .exakat.ini
fi
le at source code root

• The con
fi
g.ini
fi
le in the project directory

• The exakat.ini
fi
le in the con
fi
g directory

• Default values within the code (.exakat.yaml)
@danaluther
Command line options
https://exakat.readthedocs.io/en/latest/Administrator/Commands.html
@danaluther
Command line options
https://exakat.readthedocs.io/en/latest/Administrator/Commands.html
@danaluther
config.ini - Available Options
https://exakat.readthedocs.io/en/latest/User/Con
fi
guration.html
@danaluther
exakat.ini
https://github.com/exakat/exakat-docker/blob/master/con
fi
g/exakat.ini
@danaluther
.exakat.yaml
https://exakat.readthedocs.io/en/latest/User/Con
fi
guration.html
@danaluther
Additional configuration options
https://exakat.readthedocs.io/en/latest/User/Con
fi
guration.html
@danaluther
Run Exakat init
exakat init -p <your project name> -R <path/to/the/code> -copy
> docker container run
-
-
rm 


-
v exakat_y2s:/usr/src/exakat/projects 


-
v $(PWD):/usr/src/exakat/projects/volume_src 


exakat/exakat exakat init 


-
p Yii2Swivel
-
v 


-R /usr/src/exakat/projects/volume_src/
-
copy
@danaluther
@danaluther
Verify Initialization in the Exakat folder
@danaluther
Run Exakat project
From the project source directory
> docker container run
-
-
rm 


-
v exakat_y2s:/usr/src/exakat/projects 


-
v $(PWD):/usr/src/exakat/projects/volume_src 


exakat/exakat exakat project
-
p Yii2Swivel
-
v
@danaluther
View Generated Report
Files have been generated in our permanent exakat_y2s folder
@danaluther
@danaluther
@danaluther
Compatibility Report
PHP Version Compatibility Analysis
@danaluther
Compatibility Report
PHP Version Compatibility Analysis
@danaluther
@danaluther
@danaluther
@danaluther
@danaluther
@danaluther
@danaluther
Fixes
php-cs-
fi
xer
@danaluther
Fixes
Rector
@danaluther
Inventories
appinfo()
@danaluther
Inventories
appinfo()
@danaluther
Dead Code report
… taken with a grain of salt
@danaluther
Dead Code report
… taken with a grain of salt
@danaluther
@danaluther
Dead Code report
… taken with a grain of salt
@danaluther
Dead Code report
… taken with a grain of salt
@danaluther
Dead Code report
… taken with a grain of salt
@danaluther
Customize reports
https://exakat.readthedocs.io/en/latest/Administrator/Commands.html#report
> docker container run
-
-
rm 


-
v exakat_y2s:/usr/src/exakat/projects 


-
v $(PWD):/usr/src/exakat/projects/volume_src 


exakat/exakat exakat report
-
p Yii2Swivel 


-
format Codesniffer
-
v
@danaluther
@danaluther
Customize reports
Dependency Wheel Report
> docker container run
-
-
rm 


-
v exakat_y2s:/usr/src/exakat/projects 


-
v $(PWD):/usr/src/exakat/projects/volume_src 


exakat/exakat exakat report
-
p Yii2Swivel 


-
format DependencyWheel
-
v
@danaluther
@danaluther
@danaluther
@danaluther
Customize reports
Dependency Wheel Report
> docker container run
-
-
rm 


-
v exakat_y2s:/usr/src/exakat/projects 


-
v $(PWD):/usr/src/exakat/projects/volume_src 


exakat/exakat exakat report
-
p Yii2Swivel 


-
format owasp
-
v
@danaluther
@danaluther
@danaluther
Persistent Report Directory
Reports stored in their unique folders by default
@danaluther
Customize reports
Migration80
> docker container run
-
-
rm 


-
v exakat_y2s:/usr/src/exakat/projects 


-
v $(PWD):/usr/src/exakat/projects/volume_src 


exakat/exakat exakat report
-
p Yii2Swivel 


-
format Migration80
-
v
@danaluther
@danaluther
@danaluther
@danaluther
@danaluther
@danaluther
Migration80 Output
Suggestions - Detail
@danaluther
Other output options?
Yes! There are many, many options to choose from.
• https://exakat.readthedocs.io/en/latest/Reference/Reports.html#list-of-
reports
@danaluther
Exakat for GitHub Actions
https://hub.docker.com/r/exakat/exakat-ga
@danaluther
Upcoming Exakat Features
Cobbler - https://exakat.readthedocs.io/en/latest/User/Cobbler.html
@danaluther
Questions??
Ask now or tweet at me if you think of it later!
https://www.linkedin.com/in/danaluther
dluther@envisageinternational.com
https://joind.in/talk/b32c9
🤔
?
? ?
?

How to analyze your codebase with Exakat using Docker - Longhorn PHP