3.1 KiB
Contributing
Step-by-step guide to contributing to Mobile Detect library.
By contributing to Mobile Detect library you agree with the MIT License.
Contribute by developing code
1. Fork the repo
git clone https://github.com/[yourname]/Mobile-Detect.git
git add remote serbanghita https://github.com/serbanghita/Mobile-Detect.git
git remote -v
...
origin git@github.com:serbanghita/Mobile-Detect.git
serbanghita https://github.com/serbanghita/Mobile-Detect.git
2. Create local branch
Next create your own git working branch from one of the existing branches 4.x, 3.x or 2.x
depending on your PHP version:
git checkout -b my-new-patch origin/x.x.x
composer install
3. Lint the code
Ensure the code is clean, just run the linters:
./vendor/bin/phpcs
./vendor/bin/phpcbf
4. Run unit and integration tests
If you add new methods or make structural changes to the library then you need to add unit tests
otherwise your PR will not be accepted.
If you add new regexes make sure you commit the User-Agents in tests/providers/vendors.
Now that your changes are done, run the unit tests:
vendor/bin/phpunit -v -c tests/phpunit.xml --coverage-html .coverage
Make sure you check the .coverage folder and open the report.
The coverage should be just like you first started (close to 100%).
5. Run performance tests
./vendor/bin/phpbench run tests/Benchmark/MobileDetectBench.php --ref=baseline --retry-threshold=1 --iterations=10 --revs=1000 --report=aggregate
Baseline re-creation:
./vendor/bin/phpbench run tests/Benchmark/ --retry-threshold=1 --iterations=10 --revs=1000 --report=aggregate --tag=baseline --dump-file=phpbench-baseline.xml
6. Commit
If no errors left, then proceed to committing your changes:
git status
git stage
git commit -m "your commit message here"
git push
7. Submit PR
Now go to your repo on GitHub and "Submit the PR".
Other ways of contributing
1. Report issues
- Specify the User-agent by visiting http://demo.mobiledetect.net.
- Specify the expected behaviour.
2. Add new module, plugin, plugin or port
Submit new module, plugin, port including the following information:
- Module name
- Description
- Link
- Author
Or you can submit a PR against README.md.
3. Website updates
- Our official website is hosted at http://mobiledetect.net.
- The files are found on the
gh-pagesbranch. git checkout gh-pagesnpm install -g browser-syncbrowser-sync start --s . --f . --port 3000 --reload-debounce 1500 --no-ui- Go to
http://localhost:3000and make changes. - Commit, push and submit the PR against
serbanghita:gh-pages.