The FileLocator library was created to provide file locating capabilities to a larger project

Overview

File Locator

Build Status

A simple file locator library.

Summary

The FileLocator library was created to provide file locating capabilities to a larger project. It can be used in templating engines, configuration file loaders, and more.

Installation

Add it to your list of Composer dependencies:

$ composer require herrera-io/file-locator=1.*

Usage

The library includes FileSystemLocator, which can be used to search one or more directory paths. Either a single directory path, or an array of paths may be passed to the constructor.

locate('file.ini', false); // find all named "file.ini"">


use Herrera\FileLocator\Locator\FileSystemLocator;

$locator = new FileSystemLocator('/path/to/dir');
$locator = new FileSystemLocator(array(
    '/path/to/dir1',
    '/path/to/dir2',
    '/path/to/dir3' // etc
));

$file = $locator->locate('file.ini'); // return the first "file.ini" found
$files = $locator->locate('file.ini', false); // find all named "file.ini"

You can also create your own custom file locator by implementing the interface, LocatorInterface. All locator classes bundled in the library also implement this interface, allowing drop-in replacement.



use Herrera\FileLocator\Locator\LocatorInterface;

class MyLocator implements LocatorInterface
{
    public function locate($file, $first = true)
    {
        // do something to locate $file

        // if $first is true, return the first matching result
            // if nothing is found, return null

        // if $first is false, generate a list of found $file(s) and return it
            // if nothing is found, return an empty array
    }
}

You may use one or more file locator classes together by using the Collection class. This can be used to chain together one or more file locators, and may be used in place of an actual file locator.

locate('file.ini', false); // find all named "file.ini"">


use Herrera\FileLocator\Collection;
use Herrera\FileLocator\Locator\FileSystemLocator;
use My\Library\CustomLocator;

$locators = new Collection();
$locators->add(new FileSystemLocator('/path/to/dir'));
$locators->add(new CustomLocator());

$file = $locator->locate('file.ini'); // return the first "file.ini" found
$files = $locator->locate('file.ini', false); // find all named "file.ini"
You might also like...
The new, most powerful Comic Reader ever created by the human race. Reworked by an Otaku.
The new, most powerful Comic Reader ever created by the human race. Reworked by an Otaku.

FoOlSlideX The new, most powerful Comic Reader ever created by the human race. Reworked by an Otaku. Requirements PHP greater than 7.0 and everything

Community-created, unofficial PHP SDK for the Skynet Decentralized Internet Network. siasky.net

Skynet PHP SDK This SDK is a community-created, unofficial SDK in PHP for the Skynet Decentralized Internet Network. It is taken as primarily a port f

php-rutheeshraja created by GitHub Classroom
php-rutheeshraja created by GitHub Classroom

demo hosting of this :https://phpcomiconmail.herokuapp.com/ code is in php_rtcamp folder Index.php(demo) validation: .user need to must enter gmail ac

Allows the date format for
Allows the date format for "created", "modified" and "published" columns to be set within a Lister.

Lister Native Date Format Allows the date format for "created", "modified" and "published" columns to be set within a Lister or Lister Pro instance. W

StickWithIt is an online food ordering website created using PHP. You can view and purchase various items as well as remove items from the cart.

StickWithIt (App Name) StickWithIt is an online food ordering website created using PHP. The database used here is MYSQL database. The tool used here

A cool link aggregator created using Wordpress
A cool link aggregator created using Wordpress

A cool link aggregator created using Wordpress

A panel created based on the Zend Framework MVC framework
A panel created based on the Zend Framework MVC framework

🚀 Painel MyZap2.0 Com ZendFramework 3 Descrição Esse é um painel criado como estudo pessoal do framework (Zend Framework MVC) não foi criado para fin

Online Food Delivery Website created using HTML, CSS, PHP and MySQL which delivers food at your doorstep on Cash-On-Delivery.

Food-Delivery-Website Online Food Delivery Website created using HTML, CSS, PHP and MySQL which delivers food at your doorstep on Cash-On-Delivery. Th

PracticeCore at the time created for DarkneesNetwork, and now i publish

Practice PracticeCore for PocketMine-MP 4.0.0 Description This is a beta version, It is very likely a drop in TPS or performance and clearly errors an

Owner
KHerGe - Archived Projects
A collection of projects archived by kherge, but not deleted. Create a clone to continue a project.
KHerGe - Archived Projects
Allow multiple options for Magento 2 checkout layout. Provides capabilities to AB test checkout changes and more.

Aimes_CheckoutDesigns Features Please note: This module is currently still considered a proof of concept. This module provides the ability to change c

Rob Aimes 30 Aug 8, 2022
Magento 2 Module to add simple image resizing capabilities in all blocks and .phtml templates

Magento 2 Image Resizer Magento 2 Module to add simple image resizing capabilities in all blocks and .phtml templates Installation $ composer require

Stämpfli AG 88 Apr 18, 2022
An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods.

OrchidTables An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods. In

null 25 Dec 22, 2022
Firebird-PHP: A library created to meet a work need when handling a Firebird database

Firebird-PHP: A library created to meet a work need when handling a Firebird database

Philipe  Lima 3 Jun 27, 2022
Lock library to provide serialized execution of PHP code.

Requirements | Installation | Usage | License and authors | Donations php-lock/lock This library helps executing critical code in concurrent situation

null 875 Jan 7, 2023
Signaler library that provide stack for signal listeners.

Stack Signaler. Contents Installation Usage Testing License Installation composer require kafkiansky/signaler Usage Simple example with \SIGINT signal

kafkiansky 1 Mar 25, 2022
Roach-example-project - Example project to demonstrate how to use RoachPHP in a Laravel project.

Example repository to illustrate how to use roach-php/laravel in a Laravel app. Check app/Spiders/FussballdatenSpider.php for an example spider that c

Kai Sassnowski 11 Dec 15, 2022
File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.

Sebastian Tschan 31.1k Dec 30, 2022