Example #1
0
 public function getMigrationTemplateFilename()
 {
     $file = url_trimmer(config()->path->storage . '/stubs/db/MigrationCreate.stub');
     if (file_exists($file)) {
         return $file;
     }
     return parent::getMigrationTemplateFilename();
 }
Example #2
0
 protected function getSeedTemplateFilename()
 {
     $file = url_trimmer(config()->path->storage . '/stubs/db/SeedCreate.stub');
     if (!file_exists($file)) {
         throw new \RuntimeException("Seed Template [{$file}] not found.");
     }
     return $file;
 }
Example #3
0
 /**
  * This returns the base uri of the current module, if passed an argument
  * it automatically appended as uri.
  *
  * @param $extend_path To provide uri
  * @return string
  */
 function base_uri($extend_path = null)
 {
     if (is_cli()) {
         return;
     }
     $url = url()->getHost();
     $scheme = url()->getScheme();
     return url_trimmer($scheme . '/' . $url . '/' . $extend_path);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function slash()
 {
     chdir(url_trimmer(config()->path->root . 'public'));
     $current_dir = getcwd();
     $host = $this->input->getOption('host');
     $port = $this->input->getOption('port');
     $file = $this->input->getOption('file');
     $this->info("Phalcon Slayer development server started on http://{$host}:{$port}/");
     passthru(PHP_BINARY . " -S {$host}:{$port} -t {$current_dir} -F {$file}");
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function __construct($options)
 {
     parent::__construct($options);
     if (!is_cli()) {
         if (isset($options['session_storage']) === false) {
             $options['session_storage'] = url_trimmer(config()->path->storage . '/session');
         }
         session_save_path($options['session_storage']);
         session_set_cookie_params($options['lifetime'], $options['path'], $options['domain'], $options['secure'], $options['httponly']);
     }
 }
Example #6
0
 /**
  * Generate the compiled class file.
  *
  * @return void
  */
 protected function compileClasses()
 {
     $preloader = (new Factory())->create(['skip' => false]);
     $compile_path = config()->path->storage . '/slayer/compiled.php';
     $handle = $preloader->prepareOutput($compile_path);
     foreach ($this->getClassFiles() as $file) {
         try {
             fwrite($handle, $preloader->getCode($file, false) . "\n");
         } catch (VisitorExceptionInterface $e) {
             //
         }
     }
     fclose($handle);
     $this->info('   Compiled at ' . url_trimmer($compile_path));
 }
 /**
  * Parse the config file and load it into the config object
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws \InvalidArgumentException
  * @return void
  */
 protected function getDefaultConfig()
 {
     $env = $this->getInput()->getOption('env');
     $database_config = url_trimmer(realpath(config('path.config')) . '/' . $env . '/database.php');
     if ($env === config('old_environment')) {
         $database_config = url_trimmer(realpath(config('path.config')) . '/database.php');
     }
     if (!file_exists($database_config)) {
         throw new \RunTimeException("Database config [{$database_config}] not found.");
     }
     $selected_adapter = config('app.db_adapter');
     # to safely migrate a database, just get the specific database config
     $database = new \Phalcon\Config(require $database_config);
     $adapters = $database->adapters->toArray();
     if (!isset($adapters[$selected_adapter])) {
         throw new \RunTimeException("Adapter [{$selected_adapter}] not found " . 'on config/database.adapters');
     }
     $adapter = $adapters[$selected_adapter];
     # get the latest injected environment
     $env = config('environment');
     return new Config(['paths' => ['migrations' => realpath(config('path.migrations')), 'seeds' => realpath(config('path.seeders'))], 'environments' => ['default_migration_table' => 'migrations', 'default_database' => $env, $env => $this->getSettings($adapter)]]);
 }
Example #8
0
 /**
  * Load the configurations.
  *
  * @return $this
  */
 public function loadConfig()
 {
     # let's create an empty config with just an empty
     # array, this is just for us to prepare the config
     $this->di->setShared('config', function () {
         return new Config([]);
     });
     # get the paths and merge the array values to the
     # empty config as we instantiated above
     config(['path' => $this->paths]);
     # now merge the assigned environment
     config(['environment' => $this->getEnvironment()]);
     # iterate all the base config files and require
     # the files to return an array values
     $base_config_files = iterate_require(folder_files($this->paths['config']));
     # iterate all the environment config files and
     # process the same thing as the base config files
     $env_config_files = iterate_require(folder_files(url_trimmer($this->paths['config'] . '/' . $this->getEnvironment())));
     # merge the base config files and the environment
     # config files as one in the our DI 'config'
     config($base_config_files);
     config($env_config_files);
     return $this;
 }
 /**
  * A parser function or rebuilder to inline original file
  * into an email based html.
  *
  * @param mixed $record assigned key from inliner config
  * @return void
  */
 protected function parse($record)
 {
     # instatiate the package inliner
     $inliner = new CssToInlineStyles();
     # let's get the views dir combine the record file
     $base_file = url_trimmer(di()->get('view')->getViewsDir() . $record->file . '.*');
     # now get all related glob
     $related_files = glob($base_file);
     if (empty($related_files) === true) {
         $this->comment('   System can\'t find the file: ' . $base_file);
         return;
     }
     # set the html
     $inliner->setHTML(file_get_contents($related_files[0]));
     # set the css files
     $inliner->setCSS($this->combineCss($record['css']));
     #  get the dirname and file name
     $dirname = dirname($related_files[0]);
     $converted_name = basename($record->file) . '-inlined.volt';
     # overwrite or create a file based on the dirname and file name
     file_put_contents($dirname . '/' . $converted_name, rawurldecode($inliner->convert()));
     # log, show some sucess
     $this->comment('   ' . basename($record->file) . ' inlined! saved as ' . $converted_name);
 }
Example #10
0
 /**
  * Get the sandbox path.
  *
  * @param string $extend_path To access file by providing extended path
  * @return string
  */
 function sandbox_path($extend_path = null)
 {
     return url_trimmer(config()->path->sandbox . '/' . $extend_path);
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function slash()
 {
     # introduction
     $this->block('Welcome to the New Vendor config generator');
     $composer = new Composer();
     $package = '';
     $default = 'root/' . basename(realpath(''));
     $composer->set('name', $package = $this->ask('Package name (<vendor>/<name>) [' . $default . ']: ', $default));
     $composer = $this->otherComposerKeys($composer);
     $composer->set('autoload', ['psr-4' => [path_to_namespace($package) . '\\' => 'src/']]);
     $validation = $composer->validate();
     if ($validation['valid'] === false) {
         $this->error(json_encode($validation['errors']));
         return;
     }
     # get the file/folder writer
     $sandbox = $this->getFlysystem();
     # craft vendor folder
     $generated_path = url_trimmer($this->getSandboxPath() . $package);
     if ($sandbox->has($package) === false) {
         $this->comment("Crafting vendor folder at {$generated_path}");
         $sandbox->createDir($package);
     } else {
         $this->comment("Re-using vendor folder at {$generated_path}");
     }
     # build src folder
     if ($sandbox->has($path = $package . '/src') === false) {
         $this->comment('    - building /src folder');
         $sandbox->createDir($path);
     }
     # build the composer.json file
     if ($sandbox->has($path = url_trimmer($package . '/composer.json')) === false) {
         $this->comment('    - building composer.json file');
         $sandbox->put($path, $composer->render());
     }
     # craft <Package>ServiceProvider.php inside src/ folder
     $content = stubify($this->stubContent(), ['namespace' => path_to_namespace($package), 'serviceFile' => $service_file = path_to_namespace(basename($package)) . 'ServiceProvider']);
     if ($sandbox->has($path = $package . '/src/' . $service_file . '.php') === false) {
         $this->comment('    - building service provider class');
         $sandbox->put($path, $content);
     }
     # rebuild the base composer.json
     $composer->config(file_get_contents(base_path('composer.json')));
     if (isset($composer->toArray()['require'][$package])) {
         $this->error('Vendor already exists');
         return;
     }
     $composer->merge('require', [$package => '*']);
     $repo = str_replace(realpath('') . '/', '', $this->getSandboxPath()) . $package;
     $composer->merge('repositories', [$repo => ['type' => 'path', 'url' => $repo]]);
     $validation = $composer->validate();
     if ($validation['valid'] === false) {
         $this->error(json_encode($validation['errors']));
         return;
     }
     $this->comment('    - updating base composer.json');
     file_put_contents(base_path('composer.json'), $composer->render());
     $this->info('New vendor loaded, please run the following command:');
     $this->info(' - composer update');
 }
Example #12
0
 /**
  * This provides the routes.php file.
  *
  * Over-ride this function if you want to change the path.
  */
 public static function buildRoute($module_name)
 {
     return url_trimmer(config()->path->app . '/' . $module_name . '/routes.php');
 }
 /**
  * {@inheritdoc}
  */
 public function slash()
 {
     $this->clear(url_trimmer(storage_path('slayer')));
 }
Example #14
0
 /**
  * This loads the environment.
  *
  * @return \Clarity\Console\Brood
  */
 protected function loadEnv()
 {
     $env = $this->getInput()->getOption('env');
     $used_env = '';
     $folder = '';
     if (config('environment')) {
         $folder = $used_env = config('environment');
     }
     if ($env !== null) {
         config(['old_environment' => config('environment')]);
         config(['environment' => $env]);
         $folder = $used_env = $env;
     }
     $folder_path = url_trimmer(config()->path->config . '/' . $folder);
     if (file_exists($folder_path) === false) {
         $this->error("Config Folder [{$used_env}] not found.");
     }
     config(iterate_require(folder_files($folder_path)), $merge = false);
     return $this;
 }
Example #15
0
 /**
  * Get the namespace to use.
  *
  * @return string
  */
 protected function getNamespace($folder = 'Routes')
 {
     return url_trimmer(realpath($this->getAppPath()) . '/' . $this->getModuleName() . '/' . $folder);
 }
Example #16
0
 /**
  * Get the namespace to use.
  *
  * @return string
  */
 protected function getNamespace()
 {
     return url_trimmer($this->getAppPath() . '/' . $this->getModuleName() . '\\Controllers');
 }
Example #17
0
 protected function loadStorage($path)
 {
     $session = file_get_contents(url_trimmer($path));
     return json_decode($session, true) ?: [];
 }
Example #18
0
+----------------------------------------------------------------+
|
| call composer autoload to call all dependencies
|
*/
require $base_path . '/vendor/autoload.php';
/*
+----------------------------------------------------------------+
|\ Environmental Configuration                                  /|
+----------------------------------------------------------------+
|
| a better way to configure specific server configuration
| by creating  '.env' file in the root
|
*/
if (file_exists($base_path . '/.env')) {
    $dotenv = new Dotenv\Dotenv(dirname(url_trimmer($base_path . '/.env')));
    $dotenv->load();
}
/*
+----------------------------------------------------------------+
|\ System Start Up                                              /|
+----------------------------------------------------------------+
|
| instantiate the main kernel and set-up the configurations
| such as paths and modules
|
*/
$kernel = new Clarity\Kernel\Kernel();
$kernel->setPaths(require_once url_trimmer(__DIR__ . '/path.php'))->setEnvironment(env('APP_ENV', 'production'))->loadFactory()->loadConfig()->loadTimeZone();
return $kernel;
Example #19
0
 public function to($path)
 {
     return url_trimmer($this->getBaseUri() . '/' . $path);
 }
Example #20
0
<?php

return ['file' => ['class' => Clarity\Support\Phalcon\Session\Files::class, 'options' => ['encrypted' => true, 'session_storage' => url_trimmer(config()->path->storage . '/session')]], 'memcache' => ['class' => Phalcon\Session\Adapter\Memcache::class, 'options' => ['host' => 'localhost', 'port' => 11211, 'persistent' => false, 'lifetime' => 3600, 'prefix' => 'slayer_']], 'redis' => ['class' => Phalcon\Session\Adapter\Redis::class, 'options' => ['host' => 'localhost', 'port' => 6379, 'persistent' => false, 'lifetime' => 3600, 'prefix' => 'slayer_']]];
Example #21
0
<?php

require dirname(__DIR__) . '/vendor/classpreloader/classpreloader/src/ClassLoader.php';
$config = new \ClassPreloader\Config();
$loader = new \ClassPreloader\ClassLoader();
# - by calling the register(), this acts as a buffer to get all the
# php files loaded when calling the file autoload.php
$loader->register();
require dirname(__DIR__) . '/bootstrap/autoload.php';
$loader->unregister();
# - the listed php files below are ignored upon running the optimize
# command.
#
# - this refers a namespace closure issues, to make your optimize command
# work
$ignored = ['symfony/debug/Exception/FlattenException.php', 'swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php'];
foreach ($loader->getFilenames() as $file) {
    foreach ($ignored as $ignored_file) {
        if (strpos($file, url_trimmer($ignored_file)) !== false) {
            continue 2;
        }
    }
    $config->addFile($file);
}
return $config;
Example #22
0
 /**
  * Get the namespace to use.
  *
  * @return string
  */
 protected function getNamespace()
 {
     return url_trimmer(realpath($this->getAppPath()) . '/' . $this->getModuleName());
 }