This repo is an overly cautious Hello-World PHP script for fun. It includes the following tests and CIs to just say "Hello-World!".
- Supported PHP Version to test
- PHP v7.1, 7.2, 7.3, 7.4 (, nightly)
- Details see: .travis.yml
- Note: The nightly build version (PHP8-dev) fails on purpose in TravisCI.
- Unit Test & Code Coverage
- Coding Standard Compliance (PSR-2)
- PHP Static Analysis
- Docker for Local Testing
- Details see: docker-compose.yml
This repo uses the following CIs. On your use, register your repo first.
- TravisCI: Used for running tests.
- COVERALLS: Used for code coverage.
- Scrutinizer CI: Used for code quality.
How to
-
Choose one of the below command that suits you, to create a new project following your project name. (Ex. MyNewProject)
# For composer user (No Docker) composer create-project keinos/hello-world-tpl MyNewProject cd MyNewProject
# For composer and Docker user composer create-project --no-dev keinos/hello-world-tpl MyNewProject cd MyNewProject
# For Docker and docker-compose user (No PHP nor composer user) git clone https://github.com/KEINOS/TPL-PHP-HelloWorld.git MyNewProject cd MyNewProject rm -rf .git
Note that the project name provided (the "MyNewProject" above) will be the package name and the namespace such as "MyVendorName/MyNewProject".
-
Run the script below, which will re-write the package and vendor names to the provided name. (Ex. MyVendorName)
./.init/initialize_package.php MyVendorName
-
Before anything, run the tests to check it's basic test functionality.
composer test local all
# For Docker users composer test all
-
Create an empty Git repository and commit them.
git init git add . git commit -m 'initial commit'
-
Push the repo to GitHub then register it to the following CIs.
-
Re-name
ENVFILE.env.sample
toENVFILE.env
-
Get your access token from COVERALLS' settings and place/replace the token value in
ENVFILE.env
. -
Run tests again to see COVERALLS' function.
-
If the local test passes then commit changes and push.
-
If the tests passes on CIs then start building your project.
This repo can be develop via Docker.
If you use Visual Studio Code (a.k.a. VS Code) and have Docker installed, you can use "Remote - Containers" extension to develop your project over Docker container.
In this case, you don't need to install the packages or even PHP on your local env.
- Install Microsoft's "Remote - Containers" extension to your VS Code.
git clone
this repo to your local.- Remove the
.git
directory and initialize as a new one bygit init
. - In VSCode, open the folder in Container by F1 -> "Remote-Containers".
This repo was very much inspired by:
- このPHPがテンプレートエンジンのくせに慎重すぎる @ Qiita