ceus-media / common
Installs: 4 115
Dependents: 25
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- psr/simple-cache: ^1.0
Requires (Dev)
- ext-bz2: *
- ext-curl: *
- ext-dom: *
- ext-fileinfo: *
- ext-ftp: *
- ext-gd: *
- ext-iconv: *
- ext-imagick: *
- ext-json: *
- ext-memcache: *
- ext-pcntl: *
- ext-posix: *
- ext-simplexml: *
- ext-sockets: *
- ext-xml: *
- ext-xsl: *
- ext-zip: *
- ext-zlib: *
- ceus-media/doc-creator: ^0.9.6 | dev-master
- ceus-media/template-engine: ^0.4 | 0.4.x-dev
- erusev/parsedown: ~1.0
- michelf/php-markdown: ^1.7
- php-parallel-lint/php-parallel-lint: ^1.3 | dev-master
- phpstan/phpstan: ^1
- phpstan/phpstan-strict-rules: ^1
- phpunit/phpunit: ^9
- rector/rector: *
- dev-master
- 1.0.x-dev
- 0.9.x-dev
- 0.9.1
- 0.9.0
- 0.8.x-dev
- 0.8.6
- 0.8.5.9
- 0.8.5.8
- 0.8.5.7
- 0.8.5.6
- 0.8.5.5
- 0.8.5.4
- 0.8.5.3
- 0.8.5.2
- 0.8.5.1
- 0.8.5
- 0.8.4.9
- 0.8.4.8
- 0.8.4.7
- 0.8.4.6
- 0.8.4.5
- 0.8.4.4
- 0.8.4.3
- 0.8.4.2
- 0.8.4.1
- 0.8.4
- 0.8.3.9
- 0.8.3.8
- 0.8.3.7
- 0.8.3.6
- 0.8.3.5
- 0.8.3.4
- 0.8.3.3
- 0.8.3.2
- 0.8.3.1
- 0.8.3
- 0.8.2.7
- 0.8.2.6
- 0.8.2.5
- 0.8.2.4
- 0.8.2.3
- 0.8.2.2
- 0.8.2.1
- 0.8.2
- 0.8.1
- dev-master-merge
This package is auto-updated.
Last update: 2024-10-30 02:40:02 UTC
README
A library of PHP classes for common tasks.
Features
- Categorized classes for different basic tasks
- File and Folder indexing
- File Handling (CSV, iCal, INI, JSON, vCard, YAML, XML etc.)
- HTTP & FTP handling
- CLI handling
- HTML & image
- Data types and algorithms
- Class names with namespaces
- Typed properties
- Types method arguments
- Code quality
- PHPStan level 9 complete + extra strict rules
- Rector 7.4 rule set complete
- PHPUnit 9.5 & some unit tests
- Composer scripts for development
Usage
Installing the library via composer and packagist.
composer require ceus-media/common
Usage:
require_once 'vendor/autoload.php';
$atomDateTime = CeusMedia\Common\Net\AtomTime::get();
print 'Atom Time: '.$atomDateTime->format( DATE_COOKIE ).PHP_EOL;
This will show the current Atom Time.
Example script
require_once 'vendor/autoload.php';
use CeusMedia\Common\Alg\Time\DurationPhraser;
use CeusMedia\Common\FS\File;
$file = new File( __FILE__ );
$timeRangePhrases = [
0 => '{s} seconds',
60 => '{m} minutes',
3600 => '{h} hours',
24*3600 => 'ages'
];
$phraser = DurationPhraser::fromArray( $timeRangePhrases );
$duration = $phraser->getPhraseFromTimestamp( $file->getTime() );
echo vsprintf( 'This file (%s) has been modified %s ago.'.PHP_EOL, [
$file->getName(),
$duration,
] );
This will show the age of this script file.
From here, you could use the DurationPhraser
on other entity timestamps, like a comment, stored in a database.
Also, this example shows basic file access.
This is really just the tip of the iceberg.
Migration from 0.8.x
During migrating older projects, based on version 0.8.x, you can enable a backwards compatibility mode:
require 'vendor/ceus-media/common/src/compat8.php';
But you should not do this in production to have the best performance.