2017 © Pedro Peláez
 

library silex-finder-provider

This is a Silex service provider and a wrapper of Symfony finder

image

nachonerd/silex-finder-provider

This is a Silex service provider and a wrapper of Symfony finder

  • Saturday, September 12, 2015
  • by irgalieri
  • Repository
  • 1 Watchers
  • 0 Stars
  • 141 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Silex Finder Provider

Latest Stable Version Total Downloads Latest Unstable Version License Build Status Code Climate Test Coverage Minimum PHP Version, (*1)

SensioLabsInsight, (*2)

License

GPL-3.0, (*3)

Requirements

Install

composer require nachonerd/silex-finder-provider

Usage

Include following line of code somewhere in your initial Silex file (index.php or whatever):, (*4)

...
$app->register(new \NachoNerd\Silex\Finder\Provider());
...

Now you have access to instance of finder throw $app['nn.finder']., (*5)

Example

<?php
    require_once __DIR__.'/../vendor/autoload.php';

    $app = new Silex\Application();

    // Considering the config.yml files is in the same directory as index.php
    $app->register(new \NachoNerd\Silex\Finder\Provider());

    ...
    $finder = $app["nn.finder"];
    $finder->files()->in(__DIR__);
    foreach ($finder as $file) {
        // Dump the absolute path
        var_dump($file->getRealpath());

        // Dump the relative path to the file, omitting the filename
        var_dump($file->getRelativePath());

        // Dump the relative path to the file
        var_dump($file->getRelativePathname());
    }
    ...

What new in version 1.1.0 ?

I Add New Sort Desc methods

The methods sort in the original finder are ASC. I add DESC sort method., (*6)

  • sortByModifiedTimeDesc
<?php
    require_once __DIR__.'/../vendor/autoload.php';

    $app = new Silex\Application();

    // Considering the config.yml files is in the same directory as index.php
    $app->register(new \NachoNerd\Silex\Finder\Provider());

    ...
    $finder = $app["nn.finder"];
    $finder->files()->sortByModifiedTimeDesc()->in(__DIR__);
    foreach ($finder as $file) {
        // Dump the absolute path
        var_dump($file->getRealpath());
    }
    ...
  • sortByChangedTimeDesc
<?php
    require_once __DIR__.'/../vendor/autoload.php';

    $app = new Silex\Application();

    // Considering the config.yml files is in the same directory as index.php
    $app->register(new \NachoNerd\Silex\Finder\Provider());

    ...
    $finder = $app["nn.finder"];
    $finder->files()->sortByChangedTimeDesc()->in(__DIR__);
    foreach ($finder as $file) {
        // Dump the absolute path
        var_dump($file->getRealpath());
    }
    ...
  • sortByAccessedTimeDesc
<?php
    require_once __DIR__.'/../vendor/autoload.php';

    $app = new Silex\Application();

    // Considering the config.yml files is in the same directory as index.php
    $app->register(new \NachoNerd\Silex\Finder\Provider());

    ...
    $finder = $app["nn.finder"];
    $finder->files()->sortByAccessedTimeDesc()->in(__DIR__);
    foreach ($finder as $file) {
        // Dump the absolute path
        var_dump($file->getRealpath());
    }
    ...
  • sortByTypeDesc
<?php
    require_once __DIR__.'/../vendor/autoload.php';

    $app = new Silex\Application();

    // Considering the config.yml files is in the same directory as index.php
    $app->register(new \NachoNerd\Silex\Finder\Provider());

    ...
    $finder = $app["nn.finder"];
    $finder->files()->sortByTypeDesc()->in(__DIR__);
    foreach ($finder as $file) {
        // Dump the absolute path
        var_dump($file->getRealpath());
    }
    ...
  • sortByNameDesc
<?php
    require_once __DIR__.'/../vendor/autoload.php';

    $app = new Silex\Application();

    // Considering the config.yml files is in the same directory as index.php
    $app->register(new \NachoNerd\Silex\Finder\Provider());

    ...
    $finder = $app["nn.finder"];
    $finder->files()->sortByNameDesc()->in(__DIR__);
    foreach ($finder as $file) {
        // Dump the absolute path
        var_dump($file->getRealpath());
    }
    ...

I Add Get N First Files or Dirs

Now you can get the n first files or dirs. And if you combine this new method with the sort desc new methods you can get last first files or dirs., (*7)

<?php
    require_once __DIR__.'/../vendor/autoload.php';

    $app = new Silex\Application();

    // Considering the config.yml files is in the same directory as index.php
    $app->register(new \NachoNerd\Silex\Finder\Provider());

    ...
    $finder = $app["nn.finder"];
    $finder->files()->sortByChangedTimeDesc()->in(__DIR__);
    $finder = $finder->getNFirst(10);
    foreach ($finder as $file) {
        // Dump the absolute path
        var_dump($file->getRealpath());
    }
    ...
<?php
    require_once __DIR__.'/../vendor/autoload.php';

    $app = new Silex\Application();

    // Considering the config.yml files is in the same directory as index.php
    $app->register(new \NachoNerd\Silex\Finder\Provider());

    ...
    $finder = $app["nn.finder"];
    $finder->files()->in(__DIR__);
    $finder = $finder->getNFirst(10);
    foreach ($finder as $file) {
        // Dump the absolute path
        var_dump($file->getRealpath());
    }
    ...

The Versions

12/09 2015

dev-master

9999999-dev

This is a Silex service provider and a wrapper of Symfony finder

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

service php silex provider finder serviceprovider sort desc

12/09 2015

1.1.1

1.1.1.0

This is a Silex service provider and a wrapper of Symfony finder

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

service php silex provider finder serviceprovider sort desc

09/09 2015

1.1.0

1.1.0.0

This is a Silex service provider and a wrapper of Symfony finder

  Sources   Download

GNU GPL V3

The Requires

 

The Development Requires

service php silex provider finder serviceprovider sort desc

08/09 2015

1.0.2

1.0.2.0

Silex Service Provider to Wrapper Symfony Finder

  Sources   Download

GNU GPL V3

The Requires

 

The Development Requires

service php silex provider finder serviceprovider

08/09 2015

1.0.0

1.0.0.0

Silex Service Provider and Wrapper Symfony Finder

  Sources   Download

GNU GPL V3

The Requires

 

The Development Requires

php silex provider finder