public function __construct()
 {
     $file = new \Illuminate\Filesystem\Filesystem();
     $this->fs = $file;
     $this->concatStub = $file->get(__DIR__ . '/stubs/concat.stub');
     $this->resultConcatStub = $file->get(__DIR__ . '/stubs/resultConcat.stub');
 }
 protected function setUp()
 {
     parent::setUp();
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $items = $filesystem->getRequire(__DIR__ . '/config/config.php');
     $this->config->set('ytake-laravel-smarty', $items);
 }
示例#3
0
 /**
  * Build views in order to parse php files
  *
  * @param Array $viewPaths
  * @param String $domain
  *
  * @return Boolean status
  */
 public function compileViews(array $viewPaths, $domain)
 {
     // Check the output directory
     $targetDir = $this->storagePath . DIRECTORY_SEPARATOR . $this->storageContainer;
     if (!file_exists($targetDir)) {
         $this->createDirectory($targetDir);
     }
     // Domain separation
     $domainDir = $targetDir . DIRECTORY_SEPARATOR . $domain;
     $this->clearDirectory($domainDir);
     $this->createDirectory($domainDir);
     foreach ($viewPaths as $path) {
         $path = $this->basePath . DIRECTORY_SEPARATOR . $path;
         $fs = new \Illuminate\Filesystem\Filesystem($path);
         $files = $fs->allFiles(realpath($path));
         $compiler = new \Illuminate\View\Compilers\BladeCompiler($fs, $domainDir);
         foreach ($files as $file) {
             $filePath = $file->getRealPath();
             $compiler->setPath($filePath);
             $contents = $compiler->compileString($fs->get($filePath));
             $compiledPath = $compiler->getCompiledPath($compiler->getPath());
             $fs->put($compiledPath . '.php', $contents);
         }
     }
     return true;
 }
示例#4
0
 public function emptyCacheDirectory()
 {
     $files = new \Illuminate\Filesystem\Filesystem();
     foreach ($files->directories('storage/cache') as $directory) {
         $files->deleteDirectory($directory);
     }
 }
示例#5
0
 /**
  * @return \Illuminate\Config\Repository
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function registerConfigure()
 {
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $this->app['config']->set("ytake-laravel-aop", $filesystem->getRequire(__DIR__ . '/config/ytake-laravel-aop.php'));
     $this->app['config']->set("database", $filesystem->getRequire(__DIR__ . '/config/database.php'));
     $this->app['config']->set("cache", $filesystem->getRequire(__DIR__ . '/config/cache.php'));
     $this->app['files'] = $filesystem;
 }
示例#6
0
 /**
  * @return \Illuminate\Container\Container
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function createApplicationContainer()
 {
     $container = new \Illuminate\Container\Container();
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $container->instance('config', new \Illuminate\Config\Repository());
     $container->config->set("fluent", $filesystem->getRequire(__DIR__ . '/config/fluent.php'));
     return $container;
 }
示例#7
0
 protected function migrate()
 {
     $fileSystem = new \Illuminate\Filesystem\Filesystem();
     $classFinder = new Illuminate\Filesystem\ClassFinder();
     foreach ($fileSystem->files(__DIR__ . "/../database") as $file) {
         $fileSystem->requireOnce($file);
         $migrationClass = $classFinder->findClass($file);
         (new $migrationClass())->up();
     }
 }
示例#8
0
 protected function setUp()
 {
     $this->config = new \Illuminate\Config\Repository();
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $items = $filesystem->getRequire(__DIR__ . '/config/config.php');
     $this->config->set("ytake-laravel-smarty", $items);
     new \Illuminate\Config\Repository();
     $viewFinder = new \Illuminate\View\FileViewFinder($filesystem, ['views'], ['.tpl']);
     $this->factory = new \Ytake\LaravelSmarty\SmartyFactory(new \Illuminate\View\Engines\EngineResolver(), $viewFinder, new \Illuminate\Events\Dispatcher(), new Smarty(), $this->config);
     $this->factory->setSmartyConfigure();
     $this->factory->addSmartyExtension();
     $this->factory->resolveSmartyCache();
 }
 public function index(Request $request)
 {
     if (sha1('index' . $this->secretKey) !== $request->input('auth')) {
         abort(401, 'Not authorized');
     }
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $dirs = $filesystem->directories($this->path);
     $directories = [];
     foreach ($dirs as $dir) {
         $directories[$this->removePath($dir)] = $this->getFilenames($filesystem->files($dir));
     }
     return response()->json($directories);
 }
示例#10
0
    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        $databaseConfig = array();
        $environment = $this->ask('What is your current environment? [Default=local] : ', 'local');
        $databaseConfig['databaseHost'] = $this->ask('Enter your database host [Default=localhost] : ', 'localhost');
        $databaseConfig['databaseName'] = $this->ask('Enter your database name [Default=homestead] : ', 'homestead');
        $databaseConfig['databaseUsername'] = $this->ask('Enter your database username [Default=homestead] : ', 'homestead');
        $databaseConfig['databasePassword'] = $this->secret('Enter your database password [Default=secret] : ') ?: 'secret';
        $databaseConfig['databasePortNumber'] = $this->ask('Enter your database port number [Default=5432] : ', '5432');
        $file = new \Illuminate\Filesystem\Filesystem();
        $contents = <<<ENV
<?php
define("LARAVEL_ENV", '{$environment}');
ENV;
        $file->put(base_path() . '/bootstrap/env.php', $contents);
        $databaseConfig['environment'] = $environment;
        $config = View::make('command.runtime-conf', $databaseConfig);
        if (!$file->isDirectory(base_path() . '/app/config/propel/')) {
            $file->makeDirectory(base_path() . '/app/config/propel');
        }
        $file->put(base_path() . '/app/config/propel/runtime-conf.xml', $config);
        $file->put(base_path() . '/app/config/propel/buildtime-conf.xml', $config);
        exec('vendor/bin/propel config:convert-xml --output-dir="app/config/propel" --input-dir="app/config/propel"');
        $dbContent = <<<ENV
<?php

return array(
    'default' => 'pgsql',

    'connections' => array(

        'pgsql' => array(
            'driver'   => 'pgsql',
            'host'     => '{$databaseConfig['databaseHost']}',
            'database' => '{$databaseConfig['databaseName']}',
            'username' => '{$databaseConfig['databaseUsername']}',
            'password' => '{$databaseConfig['databasePassword']}',
            'charset'  => 'utf8',
            'prefix'   => '',
            'schema'   => 'public',
        ),

    ),

);

ENV;
        if (!$file->isDirectory(base_path() . '/app/config/' . $environment)) {
            $file->makeDirectory(base_path() . '/app/config/' . $environment);
        }
        $file->put(base_path() . '/app/config/' . $environment . '/database.php', $dbContent);
        $this->info('You are done.');
    }
示例#11
0
 public function getCartListElement()
 {
     $fileSystem = new \Illuminate\Filesystem\Filesystem();
     if ($fileSystem->exists(DIR_BASE . '/application/elements/cart_list.php')) {
         View::element('cart_list', array('cart' => StoreCart::getCart()));
     } else {
         View::element('cart_list', array('cart' => StoreCart::getCart()), 'vivid_store');
     }
 }
示例#12
0
 protected function setUp()
 {
     $this->config = new \Illuminate\Config\Repository();
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $items = $filesystem->getRequire(__DIR__ . '/config/config.php');
     $this->config->set("ytake-laravel-smarty", $items);
     new \Illuminate\Config\Repository();
     $viewFinder = new \Illuminate\View\FileViewFinder($filesystem, ['views'], ['.tpl']);
     $this->factory = new \Ytake\LaravelSmarty\SmartyFactory(new \Illuminate\View\Engines\EngineResolver(), $viewFinder, new \Illuminate\Events\Dispatcher(), new Smarty(), $this->config);
     $this->factory->setSmartyConfigure();
     $this->factory->resolveSmartyCache();
     $extension = $this->config->get('ytake-laravel-smarty.extension', 'tpl');
     $this->factory->addExtension($extension, 'smarty', function () {
         // @codeCoverageIgnoreStart
         return new \Ytake\LaravelSmarty\Engines\SmartyEngine($this->factory->getSmarty());
         // @codeCoverageIgnoreEnd
     });
 }
示例#13
0
 public function prepareFolder()
 {
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     foreach ($filesystem->glob(TEST_PATH . DIRECTORY_SEPARATOR . '{,.}*', GLOB_BRACE) as $file) {
         switch (basename($file)) {
             case 'vendor':
             case 'composer.json':
             case '.':
             case '..':
                 continue;
             default:
                 if (is_dir($file)) {
                     $filesystem->deleteDirectory($file);
                 } else {
                     $filesystem->delete($file);
                 }
         }
     }
 }
 /**
  * @return \Illuminate\Config\Repository
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 protected function registerConfigure()
 {
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $this->app['config']->set("database", $filesystem->getRequire(__DIR__ . '/config/database.php'));
     $this->app['config']->set("cache", $filesystem->getRequire(__DIR__ . '/config/cache.php'));
     $this->app['config']->set("session", $filesystem->getRequire(__DIR__ . '/config/session.php'));
     $this->app['config']->set("queue", $filesystem->getRequire(__DIR__ . '/config/queue.php'));
     $this->app['config']->set("app", $filesystem->getRequire(__DIR__ . '/config/app.php'));
     $this->app['files'] = $filesystem;
 }
示例#15
0
 /**
  * Remove old chunks
  */
 protected function removeOldData($filePath)
 {
     if ($this->storage->exists($filePath) && $this->storage->lastModified($filePath) < time() - $this->maxFileAge) {
         $this->storage->delete($filePath);
     }
 }
示例#16
0
<?php

use Intervention\Image\ImageManagerStatic as Image;
include __DIR__ . '/vendor/autoload.php';
$filesystem = new Illuminate\Filesystem\Filesystem();
$flags = $filesystem->files('input');
$countries = Country::all();
foreach ($flags as $flag) {
    $country = basename($flag, '.png');
    if (isset($countries[$country])) {
        $path = strtolower('output/' . $countries[$country] . '.png');
        $img = Image::make($flag);
        $img->resize(16, null, function ($constraint) {
            $constraint->aspectRatio();
        });
        $img->save($path);
    }
}
示例#17
0
 */
use Illuminate\Remote;
use Syncer\SSH;
use Syncer\Credential\SshPubkeyAuthCredential;
$conn = ['name' => 'lmodev', 'host' => 'lmodev2.lmo.com', 'username' => 'vimdev', 'auth' => ['key' => '/Users/goce/.ssh/passless_key']];
$dbCred = ['db-name' => 'ncarb_demo', 'host' => 'localhost', 'username' => "root", 'password' => 'root'];
/*
$connection = new Remote\Connection('remote', 'lmodev2.lmo.com', 'vimdev',
  ['key' => $conn['auth']['key']]);
$connection->run("ls -all", function ($line) {
  echo "printing line" . PHP_EOL;
});*/
/* Dump a DB Connection */
$db = new \Syncer\Credential\DatabaseCredential($dbCred['db-name'], $dbCred['username'], $dbCred['password']);
//$adapter = new \League\Flysystem\Adapter\Local('/tmp');
$temp = new \Illuminate\Filesystem\Filesystem();
$dbDumpName = "db.dump." . $db->name() . "__" . time();
$localPath = '/tmp/' . $dbDumpName;
$temp->put($localPath, "test");
$temp->exists($localPath) ? print "Hell YES" : (print "NOOOOooooooo!");
//$adapter->write($dbDumpName,"test");
/* Make a remote SSH Connection
$cred = new SshPubkeyAuthCredential($conn['name'],$conn['host'],$conn['username'],$conn['auth']['key']);

$ssh = new SSH('default',$cred);

$ssh->run('ls -all',function($line){
  echo "printing line" . PHP_EOL;
  echo $line;
});
/**/
 /**
  * MockConfig constructor.
  */
 public function __construct()
 {
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $services = $filesystem->getRequire(__DIR__ . '/config/services.php');
     array_set($this->item, 'services.sendgrid', $services['sendgrid']);
 }
示例#19
0
 /**
  * Create the image HTTP headers
  *
  * @param
  *            string path to the file to server (either default or cached version)
  */
 private function _create_headers($file_data)
 {
     // Create the required header vars
     $last_modified = gmdate('D, d M Y H:i:s', filemtime($file_data)) . ' GMT';
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $content_type = $filesystem->mimeType($file_data);
     //         $content_type = \Illuminate\Filesystem\Filesystem::mimeType($file_data);
     $content_length = filesize($file_data);
     $expires = gmdate('D, d M Y H:i:s', time() + $this->config['cache_expire']) . ' GMT';
     $max_age = 'max-age=' . $this->config['cache_expire'] . ', public';
     // Some required headers
     header("Last-Modified: {$last_modified}");
     header("Content-Type: {$content_type}");
     header("Content-Length: {$content_length}");
     // How long to hold in the browser cache
     header("Expires: {$expires}");
     /**
      * Public in the Cache-Control lets proxies know that it is okay to
      * cache this content.
      * If this is being served over HTTPS, there may be
      * sensitive content and therefore should probably not be cached by
      * proxy servers.
      */
     header("Cache-Control: {$max_age}");
     // Set the 304 Not Modified if required
     $this->_modified_headers($last_modified);
     /**
      * The "Connection: close" header allows us to serve the file and let
      * the browser finish processing the script so we can do extra work
      * without making the user wait.
      * This header must come last or the file
      * size will not properly work for images in the browser's cache
      */
     header("Connection: close");
 }
示例#20
0
文件: routes.php 项目: az-iar/tools
*/
$app->get('/', function () use($app) {
    return view('home');
});
$app->get('coupons/generate', function () use($app) {
    return view('coupons.generate');
});
$app->post('coupons/generate', function (Request $request) use($app) {
    $title = 'momo@' . time();
    $csvFile = $request->file('coupon_codes');
    $templateFile = $request->file('coupon_template');
    $csv = Reader::createFromPath($csvFile->getRealPath());
    $csv->setNewline("\r");
    $headers = $csv->fetchOne();
    $rows = $csv->setOffset(1)->fetchAll();
    $imageManager = new ImageManager();
    $filesystem = new \Illuminate\Filesystem\Filesystem();
    $filesystem->makeDirectory(storage_path('app/coupons/' . $title), 0777, true);
    //dd($rows);
    foreach ($rows as $row) {
        $code = $row[0];
        $template = $imageManager->make($templateFile->getRealPath());
        $template->text($code, 620, 310, function ($font) {
            $font->file(storage_path('app/fonts/Lato-Regular.ttf'));
            $font->size(24);
            $font->align('center');
        });
        $template->save(storage_path('app/coupons/' . $title . '/' . $code . '.' . $templateFile->getClientOriginalExtension()));
    }
    echo 'Done';
});
示例#21
0
 public function getSeedMaleAvatar()
 {
     $FILE = new \Illuminate\Filesystem\Filesystem();
     $files = $FILE->files('/Users/vicens/www/meigui/public/uploads/avatar');
     try {
         transaction();
         foreach ($files as $path) {
             $file = $FILE->name($path) . '.jpg';
             $user = User::where('sex', UserEnum::SEX_MALE)->whereNull('avatar')->first();
             if ($user && !$user->getOriginal('avatar')) {
                 $user->update(array('avatar' => $file));
             }
         }
         commit();
         return '添加成功';
     } catch (\Exception $e) {
         rollback();
         return $e->getMessage();
     }
 }
示例#22
0
 /**
  * put
  *
  * Create a file a file with the specified content
  *
  * @param string $path
  * @param string $content
  * @param string $directory (optional)
  * @param bool $createDirIfNotExists (optional)
  * @return BinaryFile
  */
 public static function put($filename, $content, $directory = self::TMP_FOLDER_NAME, $createDirIfNotExists = true)
 {
     $fileSystem = new \Illuminate\Filesystem\Filesystem();
     $directory = self::resolvePath($directory);
     if ($createDirIfNotExists && !$fileSystem->exists($directory)) {
         $fileSystem->makeDirectory($directory . DIRECTORY_SEPARATOR, 0755, true, true);
     }
     $path = $directory . DIRECTORY_SEPARATOR . $filename;
     $fileSystem->put($path, $content);
     return new BinaryFile($path);
 }
示例#23
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
$file = new Illuminate\Filesystem\Filesystem();
$parser = new Rtablada\LiterateRoutes\Parser();
$fileParser = new Rtablada\LiterateRoutes\FileParser($file, $parser);
$expected = $file->get(__DIR__ . '/tests/files/route-full.php.test');
$fileParser->buildForDirectory(__DIR__ . '/tests');
$actual = $file->get(__DIR__ . '/tests/files/route-full.php');
if ($expected == $actual) {
    echo "File built correctly.";
} else {
    echo "File build fail.";
}
$file->delete(__DIR__ . '/tests/files/route-full.php');
示例#24
0
<?php

$filesystem = new \Illuminate\Filesystem\Filesystem();
$sharedConfig = json_decode($filesystem->get(base_path('node/config.json')), true);
return ['config' => base_path(env('SATIS_CONFIG', 'resources' . DIRECTORY_SEPARATOR . 'satis.json')), 'composer_home' => base_path(env('COMPOSER_HOME', 'storage' . DIRECTORY_SEPARATOR . 'composer')), 'composer_cache' => base_path(env('COMPOSER_HOME', 'storage' . DIRECTORY_SEPARATOR . 'composer/cache')), 'memory_limit' => '2G', 'build_verbosity' => 'vvv', 'private_repository' => 'private', 'public_repository' => 'public', 'proxy' => ['http' => env('SATIS_HTTP_PROXY', null), 'https' => env('SATIS_HTTPS_PROXY', null)], 'default_repository_type' => 'vcs', 'repository_types' => ['vcs', 'pear', 'composer', 'artifact', 'path'], 'build_directory' => base_path('public'), 'public_mirror' => storage_path('app' . DIRECTORY_SEPARATOR . 'public.json'), 'private_mirror' => storage_path('app' . DIRECTORY_SEPARATOR . 'private.json'), 'lock' => base_path($sharedConfig['lock_file']), 'node' => $sharedConfig, 'sync_timeout' => 120, 'webpack_dev_server' => env('WEBPACK_DEV_SERVER', 'http://localhost:9001')];
示例#25
0
 /**
  * Prepare public asset URL for filename-based cache busting.
  * More details https://github.com/h5bp/html5-boilerplate/blob/master/.htaccess
  *
  * @param  string  $file
  * @param  string  $url
  * @return string
  */
 function cache_buster($file)
 {
     $files = new \Illuminate\Filesystem\Filesystem();
     $path = rtrim(app()->basePath('public/'), '/') . DIRECTORY_SEPARATOR . $file;
     if ($files->exists($path)) {
         $filename = substr($file, 0, -strlen($files->extension($path)) - 1);
         $buster = $files->lastModified($path);
         $ext = $files->extension($path);
         return \Illuminate\Support\Facades\URL::to($filename . '.' . $buster . '.' . $ext);
     }
     throw new \Illuminate\Filesystem\FileNotFoundException("File does not exist at path {$path}");
 }