liberty_code / file
Library
Requires
- php: ~7 || ~8
- liberty_code/data: ^1.0.
- liberty_code/di: ^1.0.
- liberty_code/library: ^1.0.
- liberty_code/register: ^1.0.
- liberty_code/view: ^1.0.
This package is auto-updated.
Last update: 2024-10-28 05:24:06 UTC
README
Description
Library contains file components, to manage files and use file system features, for other libraries components.
Requirement
- Script language: PHP: version 7 || 8
Installation
Several ways are possible:
Composer
Requirement
It requires composer installation. For more information: https://getcomposer.org
Command: Move in project root path
cd "<project_root_path>"
Command: Installation
php composer.phar require liberty_code/file ["<version>"]
Note
Include vendor
If project uses composer, vendor must be included:
require_once('<project_root_path>/vendor/autoload.php');
Configuration
Installation command allows to add, on composer file "
{ "require": { "liberty_code/file": "<version>" } }
Include
Download
- Download following repository.
- Put it on repository root path.
Include source
require_once('<repository_root_path>/include/Include.php');
Usage
File
File allows to get information and content, for specific file.
Elements
File
Allows to design a file, which is an item containing configuration, to get specific file information and content.
Base64File
Extends file features. Allows to get file information and content, from specified base 64 data source.
NameFile
Extends file features. Allows to design a named file, to get file name information.
FsFile
Extends named file features. Allows to get file information and content, from file system.
FileFactory
Allows to design file factory, to provide new or specified file instances, from specified configuration.
StandardFileFactory
Extends file factory features. Provides file instance.
NameFileFactory
Extends file factory features. Provides named file instance.
// Get file factory
use liberty_code\file\file\factory\name\model\NameFileFactory;
$fileFactory = new NameFileFactory();
...
// Get new file from configuration
$file = $fileFactory->getObjFile(array(...));
...
Register
Register using file system as storage support.
Elements
DirRegister
Allows to manage items, using file system as support. It use specific directory, where each item stored on specific file.
Example
use liberty_code\file\register\directory\model\DirRegister;
$register = new DirRegister();
...
$register->putItem('key_1', '...'); // Register specified item for key 1
$register->putItem('key_N', '...'); // Register specified item for key N
...
foreach($register->getTabKey() as $key) {
var_dump($register->getItem($key));
}
/**
* Show:
* item for key 1
* item for key N
*/
...
Template repository
Template repository used on view, using file system as storage support.
Elements
DirTmpRepository
Extends template repository features. It uses list of directory paths, where template files located, to load and get specified template content.
Example
// Get repository
use liberty_code\file\view\template\repository\directory\model\DirTmpRepository;
$repository = new DirTmpRepository([
'dir_path' => ['... directory path']
]);
...
// Get template content, if required
if($repository->checkExists('template_key'))
{
var_dump($repository->getStrContent('template_key'));
}
...