Skip to content

Commit

Permalink
feat: add support for laravel 7 and 8 (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: Akhmad Salafudin <axmad386@gmail.com>
  • Loading branch information
lakuapik and axmad386 committed Jun 13, 2022
1 parent b5f4390 commit 1b961db
Show file tree
Hide file tree
Showing 17 changed files with 508 additions and 9,792 deletions.
15 changes: 8 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/tests export-ignore

.github/ export-ignore
tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php-cs-fixer.php export-ignore
phpunit.xml export-ignore
77 changes: 77 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: "Run Tests"

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- laravel: 9.*
php: 8.1
testbench: ^7.0
stability: prefer-stable
- laravel: 9.*
php: 8.1
testbench: ^7.0
stability: prefer-lowest
- laravel: 9.*
php: 8.0
testbench: ^7.0
stability: prefer-stable
- laravel: 9.*
php: 8.0
testbench: ^7.0
stability: prefer-lowest
- laravel: 8.*
php: 8.0
testbench: ^6.0
stability: prefer-stable
- laravel: 8.*
php: 8.0
testbench: ^6.0
stability: prefer-lowest
- laravel: 8.*
php: 7.4
testbench: ^6.0
stability: prefer-stable
- laravel: 8.*
php: 7.4
testbench: ^6.0
stability: prefer-lowest
- laravel: 7.*
php: 7.4
testbench: ^5.0
stability: prefer-stable
- laravel: 7.*
php: 7.4
testbench: ^5.0
stability: prefer-lowest
- laravel: 7.*
php: 7.3
testbench: ^5.0
stability: prefer-stable
- laravel: 7.*
php: 7.3
testbench: ^5.0
stability: prefer-lowest
#
name: Laravel ${{ matrix.laravel }} with PHP ${{ matrix.php }} - ${{ matrix.stability }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: zip, pdo, sqlite, pdo_sqlite
coverage: none
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" \
"orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: composer pest
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vendor/
.php-cs-fixer.cache
.phpunit.result.cache
vendor/
composer.lock
testing.sh
207 changes: 31 additions & 176 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,184 +1,39 @@
<?php

// Thanks to https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200#gistcomment-3755709

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$rules = [
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => [
'statements' => [
'return',
],
],
'braces' => true,
'cast_spaces' => true,
'class_attributes_separation' => [
'elements' => [
'const' => 'one',
'method' => 'one',
'property' => 'one',
'trait_import' => 'none',
],
],
'class_definition' => [
'multi_line_extends_each_single_line' => true,
'single_item_single_line' => true,
'single_line' => true,
],
'concat_space' => [
'spacing' => 'none',
],
'constant_case' => [
'case' => 'lower',
],
'declare_equal_normalize' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => true,
'function_declaration' => true,
'function_typehint_space' => true,
'general_phpdoc_tag_rename' => true,
'heredoc_to_nowdoc' => true,
'include' => true,
'increment_style' => [
'style' => 'post',
],
'indentation_type' => true,
'line_ending' => true,
'linebreak_after_opening_tag' => true,
'lowercase_cast' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'method_argument_space' => true,
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
'native_function_casing' => true,
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_closing_tag' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => [
'tokens' => [
'extra',
'throw',
'use',
],
],
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => [
'use' => 'echo',
],
'no_multiline_whitespace_around_double_arrow' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => [
'positions' => [
'inside',
'outside',
],
],
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => [
'statements' => [
'break',
'clone',
'continue',
'echo_print',
'return',
'switch_case',
'yield',
],
],
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => [
'sort_algorithm' => 'alpha',
],
'phpdoc_indent' => true,
'phpdoc_inline_tag_normalizer' => true,
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_tag_type' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'psr_autoloading' => true,
'self_accessor' => true,
'short_scalar_cast' => true,
'simplified_null_return' => false,
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => [
'comment_types' => [
'hash',
],
],
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => [
'elements' => [
'arrays',
],
],
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
'property',
'method',
'const',
],
],
'whitespace_after_comma_in_array' => true,
];

$finder = Finder::create()
$finder = Symfony\Component\Finder\Finder::create()
->in([
__DIR__.'/src',
__DIR__.'/tests',
__DIR__ . '/src',
__DIR__ . '/tests',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return (new Config())
->setFinder($finder)
->setRules($rules)
->setRiskyAllowed(true)
->setUsingCache(true);
return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
16 changes: 4 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
# Changelog

Semua perubahan penting pada proyek ini akan didokumentasikan dalam file ini.
All notable changes to `laravel-api-response` will be documented in this file.

Formatnya didasarkan pada [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
dan proyek ini mematuhi [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0](https://github.com/semarangplaza/laravel-api-response/compare/v1.0.0...v1.1.0) - 14 December 2021

## Added
- ApiException secara default return status HTTP_BAD_REQUEST

## [1.0.0](https://github.com/semarangplaza/laravel-api-response/compare/207e572...v1.0.0) - 16 November 2021
## [v1.0.0](https://github.com/kodepandai/laravel-indonesia/compare/b5f439...v1.0.0) - Unreleased

### Added

- Fungsi `ApiResponse::success` dan `ApiResponse::error`
- Exception `ApiException` dan `ApiValidationException`
- ApiResponse `ApiResponse::success` and `ApiResponse::error`
- Exception `ApiException` and `ApiValidationException`
22 changes: 17 additions & 5 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
Copyright 2022 KodePandai
# The MIT License (MIT)

All rights reserved.
Copyright (c) 2022 Kode Pandai - https://github.com/kodepandai

=====
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

Hak Cipta 2022 KodePandai
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

Seluruh hak cipta dilindungi undang-undang.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 1b961db

Please sign in to comment.