A small simple implementation (and experiment) of hexagonal/port & adapters architecture using PHP
This assumes that you have the following:
- git
- Docker (with compose)
- Clone repo:
git clone https://github.com/tshiamobhuda/aoc-php-solver.git - Install dependencies:
./start.sh
You might need a chmod +x ./start.sh if you don't have permissions to run the script. The script uses docker compose to bring up a aoc-solver container (with a bash shell open in TTY mode).
The purpose of this project is to help lessen the pain of setting up a dev environment to solve Advent of Code challenges using PHP... (it should allow you to generate solutions for any day or yearday[i.e Day1.php or Day202301.php])
To generate a boilerplate solution file for the day you want to solve, run the below command in the docker container shell. Provide a numeric value when answering the "What is the day?" question
./bin/generateTwo .txt files day.<dayNumber>.test.txt, day.<dayNumber>.txt and a Day<dayNumber>.php file will be created in src/Resource/Input and src/Resources/Solution respectively.
- You can copy+paste you test & final puzzle input into the
.txtfiles. - The
Day<dayNumber>.phpfile should be used to add logic to solve the two parts of each Advent of code challenge.
To test a solution file for the day you want to solve, run the following command in the docker container shell.
./app <dayNumber> [<part>] -d Where <dayNumber> is the Advent of code day, <part> is the Advent of code puzzle part (defaults to a, other option is b), and -d is an optional flag used to run solution against test input.
The same command can be used without the -d flag to run the solution against 'final' puzzle input.
Run ./bin/generate -h or ./app -h to bring up the help page for each command.