Giter Site home page Giter Site logo

laravel-base's Introduction

Laravel base project

Current version: Laravel 5.7.15

TODO

  • Add document
  • Refactor architecture
  • ...

Debug tools

  • Laravel Debugbar: disabled by default, enable it by env variable DEBUGBAR_ENABLED=true
  • Log database queries: disabled by default, enable it by env variable DEBUG_LOG_QUERIES=true, queries will be logged to storage/logs/queries.log

Static analyze

Check potential PHP errors before run on server with phpstan,

Within project root folder, run composer phpstan

Or run for specific files or folders composer phpstan -- --paths=app/,tests/

You can also setup code editor for realtime feedback, e.g. vscode, sonarlint, ...

Conventions

Check code convention with phpcs.

Within project root folder, run phpcs or composer phpcs.

You can also setup code editor for realtime feedback, e.g. vscode, sublime, ... or use git hooks (see example)

We follow Framgia PHP Convention with some extended rules (defined in phpcs.xml)

  • Auto check in both app/ and config folders
  • Not allow whitespace on blank line
    -    
    +
  • Must have one space before and after operators +-*/:?
    - $result = $balance*$rate;
    + $result = $balance * $rate;
  • Must have one line after each class member
    <?php
    class MyClass
    {
    -    private $propertyA;
    -    private $propertyB;
    +    private $propertyA;
    +
    +    private $propertyB;
    
        public function methodA()
        {
            //
        }
    +
        public function methodB()
        {
            //
        }
    }

PHPUnit

Before running unit test, please make file .env.testing

cp .env.testing.example .env.testing

And setup database connection if needed.

Running unit test:

  • composer test for all tests in folder tests/
  • composer test tests/Unit/ExampleTest.php to test specific file
  • composer test-coverage to test and generate coverage reports in folder tests/coverage/

Docker

If you want to use docker, simple copy file docker-compose.yml.example to file docker-compose.yml and change the container prefix name project_ in file docker-compose.yml.

cp docker-compose.yml.example docker-compose.yml

Update docker-compose.yml:

# docker-compose.yml
services:
    application:
-        container_name: project_application
+        container_name: myapp_application
        image: debian

Up and running:

sudo docker-compose up -d

Your app will be available at http://localhost:8000 by default.

Update .env, e.g.

DB_HOST=mysql
REDIS_HOST=redis

Update .env.testing, e.g.

DB_HOST=mysql

To run artisan command, enter the workspace container:

sudo docker exec -it project_workspace bash

More info: https://github.com/FramgiaDockerTeam/laravel-microservices

Framgia CI

To apply Framgia CI, you can using git cherry-pick to apply ci config from dedicated branch.

For Framgia CI version 2:

git cherry-pick framgia_civ2_config

Or Framgia CI version 3:

git cherry-pick framgia_civ3_config

And follow CI service document at: https://github.com/framgiaci/documents/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.