Skip to content

Latest commit

 

History

History
103 lines (70 loc) · 3.08 KB

CONTRIBUTING.md

File metadata and controls

103 lines (70 loc) · 3.08 KB

Contributing

Before you contribute code to Laravel-Model-Base, please make sure it conforms to the PSR-2 coding standard and that the PHP_Laravel-Model-Base unit tests still pass. The easiest way to contribute is to work on your own fork.

If you do this, you can run the following commands to check if everything is ready to submit.

Guidelines of interest

Before going through the rest of this documentation, please take some time to read:

Local environment

We recommend the official php docker image:

docker run -it --rm -p 8080:80 -v "$(pwd):/opt/app" -w '/opt/app' --name php-8-1-model-base-dev php:8.1 bash

Dependencies

In order to load the dependencies, you should install composer:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer
apt-get -y update && apt-get install -y unzip zip

And run:

composer install

PSR-2 Specs

This package follows the PSR-2 coding standard.

To test if your contribution passes the standard, you can use the command:

./vendor/bin/phpcs --standard=phpcs.xml

Which should give you no output, indicating that there are no coding standard errors.

Static Analysis

php -d memory_limit=-1 vendor/bin/phpstan analyse -c phpstan.dist.neon

Unit testing

You can write your own tests and add them to the test directory.

To run the test command:

./vendor/bin/phpunit --configuration phpunit_sqlite.xml --coverage-text

Which should give you no failures or errors.

A coverage and logs will be created in the build directory.

In order to give support to older versions, you should test it also with the lowest composer packages:

composer update --prefer-stable --prefer-lowest

Test in a local laravel project

You can add the project in a directory .local within your project:

mkdir .local && git clone git@github.com:Triun/laravel-model-base.git .local/laravel-model-base

And add .local into your .gitignore file.

You can add into composer.json:

  "repositories": [
    {
      "type": "path",
      "url": "./.local/laravel-model-base"
    }
  ],

In case you find a version issue when debugging, try to change the version as:

  "triun/laravel-model-base": "^9.x-dev"