PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, May 20, 2022

[FIXED] How to easily generate a minimal php project with phpunit and composer?

 May 20, 2022     composer-php, php, phpunit     No comments   

Issue

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:

  • use PHPStorm and create a new composer project based on laravel/laravel followed by php artisan key:generate as described here and here
  • use composer init as described in this post
  • use php-pds/skeleton followed by composer require phpunit/phpunit --dev as described here

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


Solution

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 :)



Answered By - Daniele Scillia
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,259,406

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing