承接 nachonerd/silex-finder-provider 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nachonerd/silex-finder-provider

最新稳定版本:1.1.1

Composer 安装命令:

composer require nachonerd/silex-finder-provider

包简介

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

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License Build Status Code Climate Test Coverage Minimum PHP Version

SensioLabsInsight

License

GPL-3.0

Requirements

Install

composer require nachonerd/silex-finder-provider

Usage

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

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

Now you have access to instance of finder throw $app['nn.finder'].

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.

  • 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.

<?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());
    }
    ...

统计信息

  • 总下载量: 165
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2015-09-08