0

I want to solve a kata using PHP and test driven development. I would like to use a generator or template to base on a minimal composer project with phpunit.

The minimal project should contain:

  • the composer.json with phpunit as require-dev
  • the vendor folder
  • a sample tests folder with a test file and a source file

I wondered how other developers do that in PHP and found so far the following options:

What is typical way for a PHP developer to deal with the initial boilerplate in a small php project?

Adam
  • 2,800
  • 1
  • 13
  • 15
  • I would just make a simple repo with what you want and clone that as needed. The install script could then be something like `git clone https://git.example.com . && rm -rf .git/ && composer install`. I don't think you are going to find off-the-shelf things that do what you are looking for, since the setup is pretty simple. Most systems that do what you are talking about (Laravel, Symfony, etc) do it because their setups are more complex or have some best practices in place. – Chris Haas Nov 06 '20 at 22:10
  • Yes cloning some sample directory sounds not bad. That would be the pds/skeleton approach. The closest I get with a generator is using `composer require --dev pds/skeleton phpunit/phpunit && ./vendor/bin/pds-skeleton generate` that will create the right composer.json and empty project folders. – Adam Nov 06 '20 at 23:47

1 Answers1

1

I can offer you my approach as a reference:

I have a skeleton in PHP with composer and PHPUnit with a class and its test already set up. When I want to challenge a new kata, I just create a new kata and duplicate the skeleton in it (https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/duplicating-a-repository), then updates readme and class names to reflect the kata. Usually, I use master as the reference for the kata to start, and each attempt is a new branch from master.

Here is the link to my repo as a reference, you can use it as a template :)