Skip to content

Commit

Permalink
Merge pull request #31 from ADmad/cake-4.x
Browse files Browse the repository at this point in the history
Cake 4.x
  • Loading branch information
ADmad committed Mar 1, 2021
2 parents dd9fa55 + 4ef9318 commit 3de5b2e
Show file tree
Hide file tree
Showing 20 changed files with 247 additions and 243 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
phpunit.xml export-ignore
phpunit.xml.dist export-ignore
.travis.yml export-ignore
tests export-ignore
psalm.xml
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI

on: [push, pull_request]

jobs:
testsuite:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
php-version: ['7.2', '7.4', '8.0']
composer-opts: ['']
include:
- php-version: '7.2'
composer-opts: '--prefer-lowest'

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extension-csv: mbstring, intl
coverage: pcov

- name: Composer install
run: |
if [[ ${{ matrix.php-version }} == '8.0' ]]; then
composer update --ignore-platform-reqs
else
composer update ${{ matrix.composer-opts }}
fi
- name: Run PHPUnit
run: |
if [[ ${{ matrix.php-version }} == '7.4' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi
- name: Code Coverage Report
if: matrix.php-version == '7.4'
uses: codecov/codecov-action@v1

cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extension-csv: mbstring, intl
coverage: none
tools: cs2pr, psalm:^4.1

- name: Composer Install
run: composer require cakephp/cakephp-codesniffer:^4.1

- name: Run phpcs
run: vendor/bin/phpcs --report=checkstyle -q --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/ | cs2pr

- name: Run psalm
if: success() || failure()
run: psalm --output-format=github
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/composer.lock
/vendor
.phpunit.result.cache
5 changes: 0 additions & 5 deletions .scrutinizer.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .styleci.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# CakePHP Glide

[![Build Status](https://img.shields.io/travis/ADmad/cakephp-glide/master.svg?style=flat-square)](https://travis-ci.org/ADmad/cakephp-glide)
[![Build Status](https://img.shields.io/github/workflow/status/ADmad/cakephp-glide/CI/master?style=flat-square)](https://github.com/ADmad/cakephp-glide/actions?query=workflow%3ACI+branch%3Amaster)
[![Coverage Status](https://img.shields.io/codecov/c/github/ADmad/cakephp-glide.svg?style=flat-square)](https://codecov.io/github/ADmad/cakephp-glide)
[![Total Downloads](https://img.shields.io/packagist/dt/ADmad/cakephp-glide.svg?style=flat-square)](https://packagist.org/packages/ADmad/cakephp-glide)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE.txt)

CakePHP 3.x plugin to help using [Glide](http://glide.thephpleague.com/) image manipulation library.
CakePHP plugin to help using [Glide](http://glide.thephpleague.com/) image manipulation library.

The plugin consists of a middlware, view helper and a Glide response class.

## Requirements

* CakePHP 3.5+ (For 3.4 and below use 2.x, for 3.2 and below use 1.x)

## Installation

Install the plugin through composer:
Expand All @@ -21,10 +17,10 @@ Install the plugin through composer:
composer require admad/cakephp-glide
```

Load the plugin in `config/bootstrap.php`:
Load the plugin using CLI:

```
Plugin::load('ADmad/Glide');
```sh
bin/cake plugin load ADmad/Glide
```

## Usage
Expand All @@ -37,7 +33,7 @@ intercepts requests and serves images generated by Glide. For e.g.:
```php
Router::scope('/images', function ($routes) {
$routes->registerMiddleware('glide', new \ADmad\Glide\Middleware\GlideMiddleware([
// Run this filter only for URLs starting with specified string. Default null.
// Run this middleware only for URLs starting with specified string. Default null.
// Setting this option is required only if you want to setup the middleware
// in Application::middleware() instead of using router's scoped middleware.
// It would normally be set to same value as that of server.base_url below.
Expand Down Expand Up @@ -152,7 +148,7 @@ Here are the available methods of `GlideHelper`:
* See `$options` argument of `Cake\View\HtmlHelper::image()`.
* @return string Complete <img> tag.
*/
GlideHelper::image($path, array $params = [], array $options = [])
GlideHelper::image(string $path, array $params = [], array $options = []): string

/**
* URL with query string based on resizing params.
Expand All @@ -161,9 +157,9 @@ Here are the available methods of `GlideHelper`:
* @param array $params Image manipulation parameters.
* @return string Image URL.
*/
GlideHelper::url($path, array $params = [])
GlideHelper::url(string $path, array $params = []): string
```

The main benefit of using this helper is depending on the value of `secureUrls`
config, the generated URLs will contain a token which will be verified by the
dispatch filter. The prevents modification of query string params.
middleware. The prevents modification of query string params.
17 changes: 7 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "admad/cakephp-glide",
"description": "CakePHP 3.x plugin for using Glide image manipulation library.",
"description": "CakePHP plugin for using Glide image manipulation library.",
"type": "cakephp-plugin",
"keywords": [
"cakephp",
Expand Down Expand Up @@ -28,24 +28,21 @@
"issues":"https://github.com/ADmad/cakephp-glide/issues"
},
"require": {
"cakephp/cakephp": "^3.5",
"league/glide": "^1.3"
"cakephp/cakephp": "^4.0.2",
"league/glide": "^1.6"
},
"require-dev": {
"cakephp/chronos": "^1.1",
"phpunit/phpunit": "^5.7.14|^6.0"
"phpunit/phpunit": "^8.5 || ^9.3"
},
"autoload": {
"psr-4": {
"ADmad\\Glide\\": "src"
},
"files": [
"deprecations.php"
]
}
},
"autoload-dev": {
"psr-4": {
"ADmad\\Glide\\Test\\": "tests"
"ADmad\\Glide\\Test\\": "tests",
"TestApp\\": "tests/test_app/src"
}
}
}
13 changes: 0 additions & 13 deletions deprecations.php

This file was deleted.

1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<php>
Expand Down
25 changes: 25 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<MissingClosureReturnType errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />
</issueHandlers>
</psalm>
2 changes: 2 additions & 0 deletions src/Exception/ResponseException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

namespace ADmad\Glide\Exception;

use Cake\Http\Exception\NotFoundException;
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/SignatureException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

namespace ADmad\Glide\Exception;

use Cake\Http\Exception\ForbiddenException;
Expand Down

0 comments on commit 3de5b2e

Please sign in to comment.