For those of you who are still in the dark – PHP is an open-source, server-side programming language –with a big pool of PHP developers who are constantly creating and contributing PHP projects via software development platforms, such as GitHub.
However, not just anyone can create open sourced PHP projects, as they demands some basic knowledge of programming/development, and the need to follow certain standards in order to submit a project to GitHub. Read this article, compliments of Tarang Vyas (CTO at Perception System), to learn more about PHP coding.
Introduction
Open source is a sweet word for everyone belong to the software community. Therefore, 78% development companies or organizations are using open source software. Open source provides a platform where everyone wishes to contribute something and can leverage the contributions collaboratively made by others.
PHP is an open source programming language with numerous projects existing on GitHub like advanced harboring platforms. GitHub and other open source project harboring platforms have certain standards and basics that any programmer has to follow if s/he wants to contribute or participate in any programming project whether it is language, framework, or library related.
To upload and run a PHP project, you must go through its readme like documents and contribution guide available on GitHub repo in your project interface. You must have a valid license and have basic knowledge of PHP programming standards like FIG’s PSR
- PSR-2 code style guide
- PSR-4 autoloader standards
Once you are okay with basics of PHP standards, let’s see the checklist for your open source PHP projects.
No.1 – Code Quality
Writing functional code is good for a private/commercial project, but for open source project, your code should be readable as well as usable by other developers. In due course, code quality standards have defined by the PHP developer community, and you can check it using following tools.
- PHP Code Sniffer for coding standard checking
- PHP CS Fixer for fixing coding standard issues
- PHP QA tools for checking PHP code quality
- Style CI for matching coding standards with PSR-2
To check and maintain PHP coding quality and standards, you can use some selected service providers. For example,
- CodeClimate - It provides code analysis and reports by ranking your code in four GPA slabs.
- Scrutinizer CI – It offers code analysis and reporting services with extensive settings, and ranks code into ten scales.
- Sensiolabs Insight – I give code analysis and extensive code reports by ranking code with medals.
- Codacy - You can get code analysis and reports with settings, and it ranks code with alphabet scales like A, B, C, D, …
No.2 – Writing Tests
When a PHP programmer writes code, it has a purpose, and we should test the code whether it solves that purpose or not. Therefore, we should write tests according to the code like unit tests, functional tests, and integration tests.
We have two main choices of frameworks to write tests to check your code and its functionality. Those are:
- PHPUnit – It is good for test-driven development approaches for testing the code.
- PHPSpec - It is better than PHPUnit because it follows behavior driven development approaches for code testing.
No.3 – Version Control System or Continuous Integration
Host your repository on GitHub and leverage its decent offerings for version control system. It will provide you rapid feedback on what your new code did or tests. You can merge your code to the main branch using Pull Request form. It provides you a continuous integration system for your PHP code on GitHub.
The latest SVN system can help your code from crashes when anyone using in own projects. Thus, continuous integration system provides stability. I am listing two highly used Continuous Integration systems for your PHP or any open source project.
Travis CI - It is popular, fast, and easy to use.
Shippable CI - It is based on docker, but can’t run tests.
No.4 – Publish Project
Once you have accomplished setup a GitHub repository and taken steps mentioned above, it is time to publish your project to Packagist. It has a PHP package manager known as Composer, and you need to register your project using composer.json in the repo to submit it to Packages
No.5 – Writing Readme.md File
Now, you need to write Readme file with essential sections including intro, badges, installation instructions, usage or examples, testing policies or instructions, and links to contributing.md, license .md, and changelog.md files.
No.6 – Writing Changelog.md File
It is a summary of version updates made in each new version release. You should use semantic versioning for each update.
No.7 – Writing Contributing.md File
It is a kind of document guidelines for contributors and describes when they have created issues and requests in your open source PHP project. You can obtain good examples of writing it from the PHP League
No.8 – Writing License.md File
It is useless for the fresh new project but becomes significant when you start getting big traffic and usage. Based on the license you have selected, your project becomes accessible for companies or teams.
No.9 – Use Issue Board
In an open source project, developers used to create issues to request changes and add some features to your project with own views and experiences. It is a highly useful practice, and you have to organize all to respond them quickly. In due course, HuBorad can help you to show the status of issues.
No.10 – Responding Contributors
Contributors are spending their time and resource to enhance your project further, and if you ignore their contributions or requests, it goes against the etiquette of professionalism. Therefore, try to be polite and respond quickly whenever anyone contributes to your project or raise issues or requests. It will help you a lot in the long run.
Summary
Apart from the given checklist, there are many other miscellaneous things that you must check for your project. If you are interested to know in details, I cordially invite you to contact PHP development team at Perception System.
There are many talented PHP developers who have contributed and created tons of PHP projects for small to big scale and many on behalf of clients too. If you are looking for an advanced PHP project and search a suitable and eligible PHP team, don’t look back, we are your perfect choice.
Author Bio
Tarang Vyas is the Chief Technology Officer at Perception System, a leading PHP Development Company, founded in 2001.