PHPackages                             yanmarques/cloudpaths - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. yanmarques/cloudpaths

ActiveProject[File &amp; Storage](/categories/file-storage)

yanmarques/cloudpaths
=====================

A mapper to create paths for cloud storage

v1.1(7y ago)116MITPHPPHP &gt;=7.1

Since Jun 5Pushed 7y agoCompare

[ Source](https://github.com/yanmarques/cloudpaths)[ Packagist](https://packagist.org/packages/yanmarques/cloudpaths)[ RSS](/packages/yanmarques-cloudpaths/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Cloudpaths for Laravel
======================

[](#cloudpaths-for-laravel)

[![Build Status](https://camo.githubusercontent.com/91b0db21c45cd1b663bca2d4edf75d9a93e15db72905a499fc7ce39be1081a29/68747470733a2f2f7472617669732d63692e6f72672f79616e6d6172717565732f636c6f756470617468732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yanmarques/cloudpaths)[![StyleCI](https://camo.githubusercontent.com/6d698f7630a44660aabd629a991ffe48376d122de87eb9e4bfcfebe1da5e6c1d/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3133353832333330312f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/135823301)

A mapper to create dynamic urls for storing data on cloud.

Table of Contents
-----------------

[](#table-of-contents)

- [Installing](#installing)
- [Running tests](#running-tests)
- [Getting Started](#getting-started)
- [Api](#api)
    - [Mapping a new directory](#mapping-a-new-directory)
    - [Mapping an array](#mapping-an-array-of-directories)
    - [Find a directory](#find-a-directory-path-by-dot-notation-input)
    - [Find a directory replacing dynamic directories](#find-a-directory-replacing-a-dynamic-directory-name)

Installing
==========

[](#installing)

To install you can add as a dependency for your project with composer.

```
composer require yanmarques/cloudpaths
```

Running tests
=============

[](#running-tests)

Tests are good for any project, skipping tests may kill kittens.

```
./vendor/bin/phpunit -c phpunit.xml
```

Getting Started
===============

[](#getting-started)

Register the Service Provider
-----------------------------

[](#register-the-service-provider)

The package registers itself using the service provider. For this you must add the service provider to the `providers` list on your `config/app.php`.

```
'providers' => [
    ...
    Cloudpaths\CloudpathsServiceProvider::class
]
```

Facades (Optional)
------------------

[](#facades-optional)

Laravel allows us to use Facade classes as aliases for registered services on the application container. To use the Cloudpaths Facade class you must add the Facade path to the `aliases` of the `config/app.php`.

```
'aliases' => [
    ...
    Cloudpaths\Facades\Cloudpaths::class
]
```

Configuration
-------------

[](#configuration)

Once the service provider has been registered the Cloudpaths application, it will try to read the configuration from file. To configure it, you must publish the configuration file to the `config` path. Open the console and run on your project:

```
php artisan vendor:publish --provider=Cloudpaths\CloudpathsServiceProvider
```

Cloudpaths
----------

[](#cloudpaths)

The Cloudpaths class is a mapper class, which maps each directory as directory classes that implements the `Cloudpaths\Contracts\Directory.php` interface. When a new directory is been mapped, a new directory class is created, with their subdirectories, also composed by directory classes.

The `Cloudpaths\DirectoryCollection.php` collects a bunch of directories that implements the directory interface. It extends the wonderfull `Illuminate\Support\Collection.php` from Laravel, inheriting it's methods. Although the collection proxies the method that stores a new item to accepts only directory items.

- To create a new cloudpaths instance:

```
// Must implements Illuminate\Contracts\Config\Repostory interface.
$repository = new Repository;

$cloudpaths = new Cloudpaths($repository);
```

To build a new directory and it's subdirectories, the Cloudpaths uses a Factory class to handle this operation. The factory implements the `Cloudpaths\Contracts\Factory.php` interface. The default factory is the `Cloudpaths\DirFactory.php` Factory implementation, but you can implement your and pass as second argument to Cloudpaths.

Example:

```
// The custom factory that implements Cloudpaths\Contracts\Factory::class.
$cloudpaths = new Cloudpaths($repository, new CustomFactory);
```

Searcher
--------

[](#searcher)

The searcher is a search engine implemention to find for a directory by name on a given collection scope. The search engine uses scopes to change the search view. The scope will be a directory collection where only the current scope is the search target, when the scope is changed, the search is also changed.

You can implement your own searcher that implements the `Cloudpaths\Contracts\Searcher.php` interface and provide as the third argument for Cloudpaths. The default searcher is the `Cloudpaths\Search\Engine.php`.

Example:

```
$cloudpaths = new Cloudpaths($repository, $factory, new CustomSearcher);
```

Api
---

[](#api)

### Mapping a new directory:

[](#mapping-a-new-directory)

```
// A top level directory called foo is created with a subdirectory called bar.
$cloudpaths->map('foo', ['bar']);
```

### Mapping an array of directories:

[](#mapping-an-array-of-directories)

```
// A top level directory called foo is created with a subdirectory called bar.
// Another top level directory called baz is created witout subdirectories.
// The function recurses on the array, so don't worry about deep level arrays.
$cloudpaths->mapArray([
    'foo' => [
        'bar'
    ],
    'baz'
]);
```

### Find a directory path by dot notation input.

[](#find-a-directory-path-by-dot-notation-input)

You do not have to instruct the full path to the directory, just the top level directory where the directory is located and the target directory, we will find it :).

```
// The repository is configured with the root name as 'root'. The directories struture is the following.
// root
//   |--foo
//       |--bar
//           |--baz

// A Illuminate\Support\Collection is returned with all mathed paths. We want the first one.
$found = $cloudpaths->find('foo.baz')->first();

'root/foo/bar/baz'
```

### Find a directory replacing a dynamic directory name

[](#find-a-directory-replacing-a-dynamic-directory-name)

To replace, you provide an array with a key/value, the key represent the key to find and the value is the value to replace.

```
// The repository is configured with the root name as 'root'. The directories struture is the following.
// root
//   |--foo
//       |--:id
//           |--baz
// A Illuminate\Support\Collection is returned with all mathed paths. We want the first one.
// We want to change the id to a dynamic id value.
$found = $cloudpaths->find('foo.baz', [':id' => 1])->first();

'root/foo/1/baz'
```

License
=======

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

2899d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b55aa8233c7f13cf3d35090527030e8410eb70ca8dc286d98e18830e2f62b9fe?d=identicon)[yanmarques](/maintainers/yanmarques)

---

Top Contributors

[![yanmarques](https://avatars.githubusercontent.com/u/28604565?v=4)](https://github.com/yanmarques "yanmarques (111 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yanmarques-cloudpaths/health.svg)

```
[![Health](https://phpackages.com/badges/yanmarques-cloudpaths/health.svg)](https://phpackages.com/packages/yanmarques-cloudpaths)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[spatie/laravel-google-cloud-storage

Google Cloud Storage filesystem driver for Laravel

2408.9M13](/packages/spatie-laravel-google-cloud-storage)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[propaganistas/laravel-disposable-email

Disposable email validator

5762.6M6](/packages/propaganistas-laravel-disposable-email)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
