Skip to content

Commit

Permalink
[2.x] New version
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Mar 6, 2024
1 parent 1f97261 commit 28f6d4d
Show file tree
Hide file tree
Showing 32 changed files with 115 additions and 311 deletions.
152 changes: 76 additions & 76 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: Tests

Expand All @@ -9,119 +9,119 @@ on:
jobs:

byte_level:
name: "0️⃣ Byte-level"
runs-on: "ubuntu-latest"
name: 0️⃣ Byte-level
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Checkout code
uses: actions/checkout@v4

- name: "Check file permissions"
- name: Check file permissions
run: |
test "$(find . -type f -not -path './.git/*' -executable)" == ""
- name: "Find non-printable ASCII characters"
test $(find . -type f -not -path './.git/*' -executable) ==
- name: Find non-printable ASCII characters
run: |
! LC_ALL=C.UTF-8 find ./src -type f -name "*.php" -print0 | xargs -0 -- grep -PHn "[^ -~]"
! LC_ALL=C.UTF-8 find ./src -type f -name *.php -print0 | xargs -0 -- grep -PHn [^ -~]
syntax_errors:
name: "1️⃣ Syntax errors"
runs-on: "ubuntu-latest"
name: 1️⃣ Syntax errors
runs-on: ubuntu-latest
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "latest"
tools: "parallel-lint"
php-version: latest
tools: parallel-lint

- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Checkout code
uses: actions/checkout@v4

- name: "Validate Composer configuration"
run: "composer validate --strict"
- name: Validate Composer configuration
run: composer validate --strict

- name: "Check source code for syntax errors"
run: "composer exec -- parallel-lint src/"
- name: Check source code for syntax errors
run: composer exec -- parallel-lint src/

unit_tests:
name: "2️⃣ Unit and Feature tests"
name: 2️⃣ Unit and Feature tests
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
- byte_level
- syntax_errors
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
- 8.1
- 8.2
- 8.3
laravel-constraint:
- "9.*"
- "10.*"
- 10.*
- 11.*
dependencies:
- "lowest"
- "highest"
- lowest
- highest
exclude:
- laravel-constraint: "10.*"
php-version: "8.0"
- laravel-constraint: 11.*
php-version: 8.1
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
extensions: "mbstring, intl"
coverage: "xdebug"
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: xdebug

- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Checkout code
uses: actions/checkout@v4

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
- name: Install dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--with=laravel/framework:${{ matrix.laravel-constraint }}"
dependency-versions: ${{ matrix.dependencies }}
composer-options: --with=laravel/framework:${{ matrix.laravel-constraint }}

- name: "Execute unit tests"
run: "composer run-script test"
- name: Execute unit tests
run: composer run-script test

- name: "Upload coverage to Codecov"
uses: "codecov/codecov-action@v2"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4

static_analysis:
name: "3️⃣ Static Analysis"
name: 3️⃣ Static Analysis
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
- byte_level
- syntax_errors
runs-on: ubuntu-latest
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
tools: "phpstan"
php-version: "latest"
coverage: "none"
tools: phpstan
php-version: latest
coverage: none

- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Checkout code
uses: actions/checkout@v4

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
- name: Install dependencies
uses: ramsey/composer-install@v3

- name: "Execute static analysis"
run: "composer exec -- phpstan analyze -l 5 src/"
- name: Execute static analysis
run: composer exec -- phpstan analyze -l 5 src/

exported_files:
name: "4️⃣ Exported files"
name: 4️⃣ Exported files
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
- byte_level
- syntax_errors
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
- name: Checkout code
uses: actions/checkout@v4

- name: "Check exported files"
- name: Check exported files
run: |
EXPECTED="LICENSE.md,README.md,composer.json"
CURRENT="$(git archive HEAD | tar --list --exclude="src" --exclude="src/*" --exclude=".stubs" --exclude=".stubs/*" --exclude="stubs" --exclude="stubs/*" --exclude="lang" --exclude="lang/*" --exclude="config" --exclude="config/*" --exclude="database" --exclude="database/*" --exclude="resources" --exclude="resources/*" | paste -s -d ",")"
echo "CURRENT =${CURRENT}"
echo "EXPECTED=${EXPECTED}"
test "${CURRENT}" == "${EXPECTED}"
EXPECTED=LICENSE.md,README.md,composer.json
CURRENT=$(git archive HEAD | tar --list --exclude=src --exclude=src/* --exclude=.stubs --exclude=.stubs/* --exclude=stubs --exclude=stubs/* --exclude=lang --exclude=lang/* --exclude=config --exclude=config/* --exclude=database --exclude=database/* --exclude=resources --exclude=resources/* | paste -s -d ,)
echo CURRENT =${CURRENT}
echo EXPECTED=${EXPECTED}
test ${CURRENT} == ${EXPECTED}
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ Your support allows me to keep this package free, up-to-date and maintainable. A

## Requirements

* PHP 8.0 or later
* Laravel 9, 10 or later
* Laravel 10 or later
* [Opcache & Preloading enabled](https://www.php.net/manual/en/book.opcache.php) (`ext-zend-opcache`).

## Installation
Expand All @@ -30,6 +29,8 @@ Require this using Composer into your project
composer require laragear/preload
```

> [!NOTE]
>
> This package doesn't require the `ext-zend-opcache` extension to install. Just be sure to have it [enabled in your deployment server](https://www.php.net/manual/en/book.opcache.php).
## What is Preloading? Does it make my app FAST?
Expand All @@ -47,7 +48,8 @@ opcache.preload = 'www/app/preload.php';

After that, the next time PHP starts, this list of files will be preloaded automatically.

> **Note**
> [!NOTE]
>
> If you're behind a shared server, preloading may be not available for your application. Normally, shared servers also share the same PHP process, which configuration (`php.ini`) is not available for configuration. Check your server if you're not sure if Laragear Preload should be installed.
## Usage
Expand All @@ -66,6 +68,8 @@ php artisan preload:placeholder
# opcache.preload = '/www/app/preload.php';
```

> [!IMPORTANT]
>
> The command won't replace the file if it exists. You can force the operation using `--force`.
Add the preload file path in your `php.ini`:
Expand Down Expand Up @@ -168,6 +172,8 @@ The memory limit, in MegaBytes, of the List. Once this threshold is reached, no

For most applications, 32MB is fine, but you may fine-tune it for your project specifically.

> [!NOTE]
>
> This is not Opcache memory limit, as its handled separately.
#### Job configuration
Expand Down Expand Up @@ -198,6 +204,8 @@ return [

By default, the script is saved in your project root path, but you can change the filename and path to save it as long PHP has permissions to write on it. Whatever you place it, never do it in a public/accessible directory, like `public` or `storage/app/public`.

> [!IMPORTANT]
>
> Double-check your file permissions to avoid failures on production when reading the file.
#### Method
Expand Down
25 changes: 12 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Effortlessly make a Preload script for your Laravel application.",
"type": "library",
"license": "MIT",
"minimum-stability": "stable",
"minimum-stability": "dev",
"prefer-stable": true,
"keywords": [
"laravel",
Expand All @@ -21,21 +21,20 @@
}
],
"require": {
"php": "8.*",
"php": "^8.1",
"ext-json": "*",
"symfony/finder": "6.*",
"illuminate/config": "9.*|10.*",
"illuminate/console": "9.*|10.*",
"illuminate/contracts": "9.*|10.*",
"illuminate/events": "9.*|10.*",
"illuminate/http": "9.*|10.*",
"illuminate/pipeline": "9.*|10.*",
"illuminate/queue": "9.*|10.*",
"illuminate/support": "9.*|10.*"
"symfony/finder": "7.*",
"illuminate/config": "10.*|11.*",
"illuminate/console": "10.*|11.*",
"illuminate/contracts": "10.*|11.*",
"illuminate/events": "10.*|11.*",
"illuminate/http": "10.*|11.*",
"illuminate/pipeline": "10.*|11.*",
"illuminate/queue": "10.*|11.*",
"illuminate/support": "10.*|11.*"
},
"require-dev": {
"orchestra/testbench": "^7.22|8.*",
"jetbrains/phpstorm-attributes": "*"
"orchestra/testbench": "8.*|9.*"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 0 additions & 6 deletions src/Compiler/Pipes/FireEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class FireEvent
{
/**
* Create a new pipe instance.
*
* @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
*/
public function __construct(protected Dispatcher $dispatcher)
{
Expand All @@ -21,10 +19,6 @@ public function __construct(protected Dispatcher $dispatcher)

/**
* Handle the script generation.
*
* @param \Laragear\Preload\Listing $listing
* @param \Closure $next
* @return Listing
*/
public function handle(Listing $listing, Closure $next): Listing
{
Expand Down
6 changes: 0 additions & 6 deletions src/Compiler/Pipes/LoadPreloadStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class LoadPreloadStub
{
/**
* Create a new pipe instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
*/
public function __construct(protected Filesystem $files)
{
Expand All @@ -24,10 +22,6 @@ public function __construct(protected Filesystem $files)

/**
* Handle the script generation.
*
* @param \Laragear\Preload\Listing $listing
* @param \Closure $next
* @return Listing
*/
public function handle(Listing $listing, Closure $next): Listing
{
Expand Down
9 changes: 0 additions & 9 deletions src/Compiler/Pipes/UpdateListingConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class UpdateListingConfig
{
/**
* Create a new pipe instance.
*
* @param \Illuminate\Contracts\Config\Repository $config
*/
public function __construct(protected ConfigContract $config)
{
Expand All @@ -20,10 +18,6 @@ public function __construct(protected ConfigContract $config)

/**
* Handle the script generation.
*
* @param \Laragear\Preload\Listing $listing
* @param \Closure $next
* @return Listing
*/
public function handle(Listing $listing, Closure $next): Listing
{
Expand All @@ -36,9 +30,6 @@ public function handle(Listing $listing, Closure $next): Listing

/**
* Returns a list of replaceable string with Preload data.
*
* @param \Laragear\Preload\Listing $listing
* @return array
*/
protected function listConfig(Listing $listing): array
{
Expand Down
4 changes: 0 additions & 4 deletions src/Compiler/Pipes/UpdateListingFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ class UpdateListingFiles
{
/**
* Handle the script generation.
*
* @param \Laragear\Preload\Listing $listing
* @param \Closure $next
* @return Listing
*/
public function handle(Listing $listing, Closure $next): Listing
{
Expand Down
Loading

0 comments on commit 28f6d4d

Please sign in to comment.