Skip to content

mogic-le/mogic-phpcs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mogic PHP coding standard

A set of rules for PHP_CodeSniffer and PHP-CS-Fixer.

Usage

Create your own phpcs.xml file from this template and adjust it:

<?xml version="1.0"?>
<ruleset name="bellevue">
  <description>project-specific coding standard</description>

  <file>Classes</file>
  <file>eid</file>

  <exclude-pattern>*/lib/*</exclude-pattern>

  <rule ref="./vendor/mogic/mogic-phpcs/Mogic/"/>
</ruleset>

Project with composer

The repository is mirrored automatically to Github: https://github.com/mogic-le/mogic-phpcs The package is also available on packagist: https://packagist.org/packages/mogic/mogic-phpcs

Now run:

$ composer require --dev mogic/mogic-phpcs:dev-master

and create .php-cs-fixer.php with the following content:

<?php
$config = require __DIR__ . '/vendor/mogic/mogic-phpcs/.php-cs-fixer.php';

$finder = (new PhpCsFixer\Finder())
    ->in(__DIR__ . '/local_packages/');

return $config
    ->setFinder($finder);

Then commit composer.json, composer.lock and .php-cs-fixer.php.

During the build, composer install needs to be called, which will fetch the coding standard from git. To make this work, the build container needs to contain a SSH key that has read-only access to the coding standards repository.

Example: reos-docker -> web-build

Project without composer dependencies

In a project, create a composer.json file:

{
    "name": "customer/projectname",
    "description": "FIXME",
    "license": "proprietary",
    "require-dev": {
        "mogic/mogic-phpcs": "dev-master"
    }
}

Adjust Makefile:

update-phpcs:
      rm -rf vendor
      composer install
      rm -rf vendor/autoload.php vendor/composer/ vendor/mogic/mogic-phpcs/.git/

Now run make update-phpcs and git commit the vendor/ dir, composer.json and composer.lock.

Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published