Skip to content

Instantly share code, notes, and snippets.

@kiklop74
Created June 17, 2019 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kiklop74/ef3e57d5d679b9f0522ecbe372195c10 to your computer and use it in GitHub Desktop.
Save kiklop74/ef3e57d5d679b9f0522ecbe372195c10 to your computer and use it in GitHub Desktop.
Setup laravel and PHPstorm

We recommennd to install these plugins for PHPStorm

https://plugins.jetbrains.com/plugin/9525--env-files-support

https://plugins.jetbrains.com/plugin/4230-bashsupport

https://plugins.jetbrains.com/plugin/7532

Add these items to your laravel project

composer require --dev squizlabs/php_codesniffer
composer require --dev barryvdh/laravel-ide-helper

Configure PHPStorm to use PSR1/2 in it's code analysis

  • Choose File / Settings from the menu
  • Go to the Editor / Code Style / PHP page
  • In the "Scheme" dropdown choose Project
  • Locate the link "Set from" in the top right corner and click on it
  • Choose "Predefined Style / PSR1/PSR2"
  • Save

With this setting whenever you choose Code / Reformat code it will set it up according to the Laravel coding guidelines.

Configure PHPStorm to use same indenting as composer JSON

  • Choose File / Settings from the menu
  • Go to the Editor / Code Style / JSON page
  • In the "Scheme" dropdown choose Project
  • On "Tabs and Indents" tab locate the option "Indent:"
  • Set it to 4
  • Save

Recommended base Travis CI script for laravel project

  sudo: true
  
  language: php
  php:
    - 7.1.11
  
  cache:
    directories:
      - $HOME/.composer/cache
      - $HOME/.npm
  
  addons:
    apt:
      packages:
        - nasm
  
  before_install:
    - nvm install v8.9
    - nvm use v8.9
    - curl -sS -o security-checker.phar https://get.sensiolabs.org/security-checker.phar
    - composer -n --no-progress install
    - npm install
    - cp -uv .env.example .env
    - php artisan key:generate
  
  script:
    - php security-checker.phar security:check composer.lock
    - npm run dev
    - vendor/bin/phpcs --extensions='php' --ignore='*.blade.php,bootstrap,vendor,node_modules,storage,public,database,_ide_helper.php' --standard='PSR2' .
    - vendor/bin/phpunit --colors

Explanation:

  • We install NodeJS 8.9
  • We download Symphony composer security checker
  • We install all PHP and NodeJS dependencies
  • We prepare project for the use
  • We execute composer security check
  • We execute full Js build that helps detecting any potential errors
  • We check for PHP code quality using Code Sniffer
  • We execute unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment