Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Requirements:
- Filesystem operations across core modules.
- Mount support with scheme paths (`name://path`) and default filesystem support for relative paths.
- Config-driven storage bootstrap via `StorageFactory` for local/custom/adapter-based filesystems.
- Unified entry facade via `Infocyph\Pathwise\File` for file/dir/processors/storage/tooling.
- Unified entry facade via `Infocyph\Pathwise\PathwiseFacade` for file/dir/processors/storage/tooling.
- Advanced file APIs: checksum verification, visibility controls, URL passthrough (`publicUrl`, `temporaryUrl`).
- Directory automation: sync with diff report, recursive copy/move/delete, mounted-path ZIP/unzip bridging.
- Upload/download pipelines: chunked/resumable uploads, validation profiles (image/video/document), extension allow/deny controls, strict MIME/signature checks, upload-id safety validation, malware-scan hook, secure download metadata + range handling.
Expand Down Expand Up @@ -138,20 +138,20 @@ StorageFactory::mount('tenant', [
]);
```

## **Unified File Facade**
## **Unified Pathwise Facade**

Use a single entry point when you want fewer direct class imports.

```php
use Infocyph\Pathwise\File;
use Infocyph\Pathwise\PathwiseFacade;

$entry = File::at('/tmp/example.txt');
$entry = PathwiseFacade::at('/tmp/example.txt');
$entry->file()->create('hello')->append("\nworld");

$upload = File::upload();
$download = File::download();
$upload = PathwiseFacade::upload();
$download = PathwiseFacade::download();

File::mountStorage('assets', ['driver' => 'local', 'root' => '/srv/assets']);
PathwiseFacade::mountStorage('assets', ['driver' => 'local', 'root' => '/srv/assets']);
```

## **FileManager**
Expand Down
6 changes: 3 additions & 3 deletions docs/capabilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Pathwise combines two layers:
Primary Modules
---------------

Unified Facade (``Infocyph\Pathwise\File``)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unified Facade (``Infocyph\Pathwise\PathwiseFacade``)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Class:

* ``File``
* ``PathwiseFacade``

What you get:

Expand Down
42 changes: 21 additions & 21 deletions docs/file-facade.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Unified File Facade
===================
Unified Pathwise Facade
=======================

Namespace: ``Infocyph\Pathwise``

Pathwise provides ``File`` as a convenience facade when you want one entry
Pathwise provides ``PathwiseFacade`` as a convenience facade when you want one entry
point instead of importing many classes directly.

Use this when:
Expand All @@ -21,9 +21,9 @@ Path-Bound Access

.. code-block:: php

use Infocyph\Pathwise\File;
use Infocyph\Pathwise\PathwiseFacade;

$entry = File::at('/tmp/demo.txt');
$entry = PathwiseFacade::at('/tmp/demo.txt');

$entry->file()->create('hello')->append("\nworld");

Expand All @@ -43,11 +43,11 @@ Directory + Compression via Same Entry

.. code-block:: php

use Infocyph\Pathwise\File;
use Infocyph\Pathwise\PathwiseFacade;

File::at('/tmp/source')->directory()->create();
PathwiseFacade::at('/tmp/source')->directory()->create();

File::at('/tmp/archive.zip')
PathwiseFacade::at('/tmp/archive.zip')
->compression(true)
->compress('/tmp/source')
->save();
Expand All @@ -57,39 +57,39 @@ Static Gateways

.. code-block:: php

use Infocyph\Pathwise\File;
use Infocyph\Pathwise\PathwiseFacade;

$upload = File::upload();
$download = File::download();
$policy = File::policy();
$queue = File::queue('/tmp/jobs.json');
$audit = File::audit('/tmp/audit.jsonl');
$upload = PathwiseFacade::upload();
$download = PathwiseFacade::download();
$policy = PathwiseFacade::policy();
$queue = PathwiseFacade::queue('/tmp/jobs.json');
$audit = PathwiseFacade::audit('/tmp/audit.jsonl');

Storage from Facade
-------------------

``File`` delegates storage creation/mounting to ``StorageFactory``.
``PathwiseFacade`` delegates storage creation/mounting to ``StorageFactory``.

.. code-block:: php

use Infocyph\Pathwise\File;
use Infocyph\Pathwise\PathwiseFacade;

File::mountStorage('assets', [
PathwiseFacade::mountStorage('assets', [
'driver' => 'local',
'root' => '/srv/storage/assets',
]);

// For other adapters, pass adapter/constructor config:
// File::mountStorage('s3', ['driver' => 's3', 'adapter' => $adapter]);
// PathwiseFacade::mountStorage('s3', ['driver' => 's3', 'adapter' => $adapter]);

Operational Tooling from Facade
-------------------------------

Available helpers:

* ``File::retain(...)`` -> ``RetentionManager``
* ``File::index(...)`` / ``File::duplicates(...)`` / ``File::deduplicate(...)`` -> ``ChecksumIndexer``
* ``File::snapshot(...)`` / ``File::diffSnapshots(...)`` / ``File::watch(...)`` -> ``FileWatcher``
* ``PathwiseFacade::retain(...)`` -> ``RetentionManager``
* ``PathwiseFacade::index(...)`` / ``PathwiseFacade::duplicates(...)`` / ``PathwiseFacade::deduplicate(...)`` -> ``ChecksumIndexer``
* ``PathwiseFacade::snapshot(...)`` / ``PathwiseFacade::diffSnapshots(...)`` / ``PathwiseFacade::watch(...)`` -> ``FileWatcher``

See also:

Expand Down
6 changes: 3 additions & 3 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ See ``storage-adapters`` for setup patterns.
Where to Use First
------------------

If you are evaluating Pathwise, start with the unified ``File`` facade, then
If you are evaluating Pathwise, start with the unified ``PathwiseFacade`` facade, then
drop down to direct module classes as needed.

.. code-block:: php

use Infocyph\Pathwise\File;
use Infocyph\Pathwise\PathwiseFacade;

$ops = File::at('/tmp/example.txt')->file();
$ops = PathwiseFacade::at('/tmp/example.txt')->file();
$ops->create('initial')->update('updated');
8 changes: 4 additions & 4 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It focuses on three layers:

Main namespaces:

* ``Infocyph\Pathwise`` (unified ``File`` facade)
* ``Infocyph\Pathwise`` (unified ``PathwiseFacade`` facade)
* ``Infocyph\Pathwise\FileManager``
* ``Infocyph\Pathwise\DirectoryManager``
* ``Infocyph\Pathwise\StreamHandler``
Expand All @@ -37,14 +37,14 @@ Quick Start

.. code-block:: php

use Infocyph\Pathwise\File;
use Infocyph\Pathwise\PathwiseFacade;

File::at('/tmp/demo.txt')
PathwiseFacade::at('/tmp/demo.txt')
->file()
->create('hello')
->append("\nworld");

$report = File::at('/tmp/source')
$report = PathwiseFacade::at('/tmp/source')
->directory()
->syncTo('/tmp/backup', deleteOrphans: true);

Expand Down
4 changes: 2 additions & 2 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ This quickstart shows the fastest way to understand what Pathwise can do.

.. code-block:: php

use Infocyph\Pathwise\File;
use Infocyph\Pathwise\PathwiseFacade;

$file = File::at('/tmp/example.txt')->file();
$file = PathwiseFacade::at('/tmp/example.txt')->file();
$file->create("v1\n")
->append("v2\n")
->writeAndVerify("v3\n", 'sha256');
Expand Down
6 changes: 3 additions & 3 deletions src/File.php → src/PathwiseFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Infocyph\Pathwise\Utils\PathHelper;
use League\Flysystem\FilesystemOperator;

final class File
final class PathwiseFacade
{
/**
* Constructor to initialize the file path.
Expand All @@ -37,7 +37,7 @@ public function __construct(private string $path)
* Create a new instance at the given path.
*
* @param string $path The path to the file or directory.
* @return self A new File instance.
* @return self A new facade instance.
*/
public static function at(string $path): self
{
Expand Down Expand Up @@ -116,7 +116,7 @@ public static function duplicates(string $directory, string $algorithm = 'sha256
* Alias for at() - create a new instance at the given path.
*
* @param string $path The path to the file or directory.
* @return self A new File instance.
* @return self A new facade instance.
*/
public static function from(string $path): self
{
Expand Down
34 changes: 17 additions & 17 deletions tests/Feature/FileFacadeTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Infocyph\Pathwise\File;
use Infocyph\Pathwise\PathwiseFacade;
use Infocyph\Pathwise\Storage\StorageFactory;
use Infocyph\Pathwise\Utils\FlysystemHelper;

Expand All @@ -24,7 +24,7 @@

test('it provides path-bound file accessors', function () {
$filePath = $this->workspace . DIRECTORY_SEPARATOR . 'sample.txt';
$entry = File::at($filePath);
$entry = PathwiseFacade::at($filePath);

$entry->file()->create("line-1\n");

Expand Down Expand Up @@ -52,9 +52,9 @@
$zipPath = $this->workspace . DIRECTORY_SEPARATOR . 'archive.zip';
$extractDir = $this->workspace . DIRECTORY_SEPARATOR . 'extract';

File::at($sourceDir)->directory()->create();
File::at($zipPath)->compression(true)->compress($sourceDir)->save();
File::at($zipPath)->compression()->decompress($extractDir)->save();
PathwiseFacade::at($sourceDir)->directory()->create();
PathwiseFacade::at($zipPath)->compression(true)->compress($sourceDir)->save();
PathwiseFacade::at($zipPath)->compression()->decompress($extractDir)->save();

expect(FlysystemHelper::fileExists($zipPath))->toBeTrue()
->and(FlysystemHelper::fileExists($extractDir . DIRECTORY_SEPARATOR . 'a.txt'))->toBeTrue()
Expand All @@ -65,41 +65,41 @@
$root = $this->workspace . DIRECTORY_SEPARATOR . 'storage';
mkdir($root, 0755, true);

File::mountStorage('facade', [
PathwiseFacade::mountStorage('facade', [
'driver' => 'local',
'root' => $root,
]);

FlysystemHelper::write('facade://data/file.txt', 'hello');

$upload = File::upload();
$download = File::download();
$policy = File::policy()->allow('*', '*');
$upload = PathwiseFacade::upload();
$download = PathwiseFacade::download();
$policy = PathwiseFacade::policy()->allow('*', '*');

$queueFile = $this->workspace . DIRECTORY_SEPARATOR . 'queue' . DIRECTORY_SEPARATOR . 'jobs.json';
$queue = File::queue($queueFile);
$queue = PathwiseFacade::queue($queueFile);
$queue->enqueue('example', ['id' => 1], 10);
$stats = $queue->stats();

$auditFile = $this->workspace . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . 'audit.jsonl';
$audit = File::audit($auditFile);
$audit = PathwiseFacade::audit($auditFile);
$audit->log('facade.test', ['ok' => true]);

$watchPath = $this->workspace . DIRECTORY_SEPARATOR . 'watch.txt';
file_put_contents($watchPath, 'v1');
$snapshotA = File::snapshot($watchPath);
$snapshotA = PathwiseFacade::snapshot($watchPath);
file_put_contents($watchPath, 'v22');
$snapshotB = File::snapshot($watchPath);
$diff = File::diffSnapshots($snapshotA, $snapshotB);
$snapshotB = PathwiseFacade::snapshot($watchPath);
$diff = PathwiseFacade::diffSnapshots($snapshotA, $snapshotB);

$dupDir = $this->workspace . DIRECTORY_SEPARATOR . 'dups';
mkdir($dupDir, 0755, true);
file_put_contents($dupDir . DIRECTORY_SEPARATOR . 'a.txt', 'dup');
file_put_contents($dupDir . DIRECTORY_SEPARATOR . 'b.txt', 'dup');
$index = File::index($dupDir);
$duplicates = File::duplicates($dupDir);
$index = PathwiseFacade::index($dupDir);
$duplicates = PathwiseFacade::duplicates($dupDir);

$retention = File::retain($this->workspace . DIRECTORY_SEPARATOR . 'empty-retention');
$retention = PathwiseFacade::retain($this->workspace . DIRECTORY_SEPARATOR . 'empty-retention');

expect($upload)->toBeInstanceOf(\Infocyph\Pathwise\StreamHandler\UploadProcessor::class)
->and($download)->toBeInstanceOf(\Infocyph\Pathwise\StreamHandler\DownloadProcessor::class)
Expand Down
Loading