Skip to content
Vanilla PHP Package Project
PHP
Branch: master
Clone or download
Pull request Compare This branch is 49 commits behind elliotjreed:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
public
src/Example
tests/Example
.gitignore
LICENCE.md
README.md
composer.json
composer.lock
guide.md
phpunit.xml

README.md

Vanilla PHP Project

This repository shows a basic setup for a PHP package or application in PHP.

Getting Started

PHP 7 or above and Composer is expected to be installed on our system.

Installing Composer

For instructions on how to install Composer visit getcomposer.org.

Installing

After cloning this repository, change into the newly created directory and run

composer install

or if you have installed Composer locally

php composer.phar install

This will install all dependencies needed for the project.

Running the Tests

All tests can be run by executing

vendor/phpunit/phpunit/phpunit

phpunit will automatically find all tests inside the test directory and run them based on the configuration in the phpunit.xml file.

Testing Approach

The first test for the class Greeting verifies that the return value of the sayHello method contains the name of the person and also contains the initial greeting “Good”.

The second and third tests uses stubs to override the default behaviour of the DateTime class injected into the class' constructor so that we can test the expected return value depending on the time of day.

Running the Application

PHP has an in-built server for local development. To run this change into the directory public and run

php -S localhost:8000

Then open your browser at http://localhost:8000/example.php

You should see the text “Good Morning Ada Lovelace” being printed (or similar depending on the time of day).

Built With

License

This project is licensed under the MIT License - see the LICENCE.md file for details.

You can’t perform that action at this time.