1. Go to this page and download the library: Download yanmarques/cloudpaths library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Must implements Illuminate\Contracts\Config\Repostory interface.
$repository = new Repository;
$cloudpaths = new Cloudpaths($repository);
// The custom factory that implements Cloudpaths\Contracts\Factory::class.
$cloudpaths = new Cloudpaths($repository, new CustomFactory);
$cloudpaths = new Cloudpaths($repository, $factory, new CustomSearcher);
// A top level directory called foo is created with a subdirectory called bar.
$cloudpaths->map('foo', ['bar']);
// 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'
]);
// 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'
// 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'