Skip to content

Commit

Permalink
Updating codebase to PHP 8.1 with RectorPHP
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-butti committed Dec 20, 2023
1 parent 1f74a5c commit fff1aae
Show file tree
Hide file tree
Showing 27 changed files with 835 additions and 678 deletions.
52 changes: 8 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,21 @@
PHPePub allows a php script to generate ePub Electronic books on the fly, and send them to the user as downloads.

PHPePub support most of the ePub 2.01 specification, and enough of the new ePub3 specification to make valid ePub 3 books as well.
The original project was: https://github.com/Grandt/PHPePub
Then the project was forkend into: https://github.com/wallabag/PHPePub
And then we forked the project to update the codebase with a modern version of PHP. To do that we used RectorPHP to update automatically the codebase to PHP 8.1.
Then we update the style according to PER standards https://www.php-fig.org/per/coding-style/.

The projects is also hosted on PHPClasses.org at the addresses:
http://www.phpclasses.org/package/6115

PHPePub is meant to be easy to use for small projects, and still allow for comples and complete e-books should the need arise.

The Zip.php class in this project originates from http://www.phpclasses.org/package/6110

or on Github: git://github.com/Grandt/PHPZip.git

See the examples for example usage. The php files have "some" doumentation in them in the form of Javadoc style function headers.

## Installation

### Import
Add this requirement to your `composer.json` file:
```json
"wallabag/phpepub": "^4.0.3"
```

### Composer
If you already have Composer installed, skip this part.

[Packagist](https://packagist.org/), the main composer repository has a neat and very short guide.
Or you can look at the guide at the [Composer site](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx).

The easiest for first time users, is to have the composer installed in the same directory as your composer.json file, though there are better options.

Run this from the command line:
```
php -r "readfile('https://getcomposer.org/installer');" | php
```

This will check your PHP installation, and download the `composer.phar`, which is the composer binary. This file is not needed on the server though.

Once composer is installed you can create the `composer.json` file to import this package.
```json
{
"require": {
"wallabag/phpepub": "^4.0.3",
"php": ">=5.3.0"
}
}
composer require hi-folks/phpepub
```

Followed by telling Composer to install the dependencies.
```
php composer.phar install
```

this will download and place all dependencies defined in your `composer.json` file in the `vendor` directory.
## Using PHPePub

Finally, you include the `autoload.php` file in the new `vendor` directory.
```php
Expand All @@ -65,10 +29,10 @@ Finally, you include the `autoload.php` file in the new `vendor` directory.
```

## TODO:
* The goal being to encompass the majority of the features in the ePub 2.0 and 3.0 specifications, except the Daisy type files.
The goal is to encompass the majority of the features in the ePub 2.0 and 3.0 specifications, except the Daisy-type files.
* Add better handling of Reference structures.
* Improve handling of media types and linked files.
* A/V content is allowed, but definitely not recommended, and MUST have a fallback chain ending in a valid file. If no such chain is provided, the content should not be added.
* A/V content is allowed, but not recommended, and MUST have a fallback chain ending in a valid file. If no such chain is provided, the content should not be added.
* Documentation, no one reads it, but everyone complains if it is missing.
* Better examples to fully cover the capabilities of the EPub classes.
* more TODO's.
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "wallabag/phpepub",
"name": "hi-folks/phpepub",
"type": "library",
"description": "Package to create and stream e-books in the ePub 2.0 and 3.0 formats.",
"keywords": ["epub", "e-book"],
Expand Down Expand Up @@ -28,10 +28,15 @@
"name": "Kevin Decherf",
"homepage": "https://kdecherf.com",
"role": "Contributor"
},
{
"name": "Roberto Butti",
"homepage": "https://hi-folks.dev",
"role": "Contributor"
}
],
"require": {
"php": ">=5.3.0",
"php": ">=8.1.0",
"phpzip/phpzip": "~2.0.7",
"grandt/phpresizegif": "~1.0.3",
"grandt/relativepath": "~1.0.1",
Expand All @@ -44,5 +49,8 @@
"classmap": [
"src/lib.uuid.php"
]
},
"require-dev": {
"rector/rector": "^0.18.13"
}
}
17 changes: 17 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
]);
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81
]);
};
Loading

0 comments on commit fff1aae

Please sign in to comment.