当前位置: 首页>>代码示例>>PHP>>正文


PHP realpath函数代码示例

本文整理汇总了PHP中realpath函数的典型用法代码示例。如果您正苦于以下问题:PHP realpath函数的具体用法?PHP realpath怎么用?PHP realpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了realpath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     if (!file_exists($path)) {
         $output->writeln("{$path} is not a file or a path");
     }
     $filePaths = [];
     if (is_file($path)) {
         $filePaths = [realpath($path)];
     } elseif (is_dir($path)) {
         $filePaths = array_diff(scandir($path), array('..', '.'));
     } else {
         $output->writeln("{$path} is not known.");
     }
     $generator = new StopwordGenerator($filePaths);
     if ($input->getArgument('type') === 'json') {
         echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
         echo json_last_error_msg();
         die;
         $output->write(json_encode($this->toArray($generator->getStopwords())));
     } else {
         $stopwords = $generator->getStopwords();
         $stdout = fopen('php://stdout', 'w');
         echo 'token,freq' . PHP_EOL;
         foreach ($stopwords as $token => $freq) {
             fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL;
         }
         fclose($stdout);
     }
 }
开发者ID:yooper,项目名称:php-text-analysis,代码行数:30,代码来源:StopWordsCommand.php

示例2: __construct

 /**
  * Tests that the storage location is a directory and is writable.
  */
 public function __construct($filename)
 {
     // Get the directory name
     $directory = str_replace('\\', '/', realpath(pathinfo($filename, PATHINFO_DIRNAME))) . '/';
     // Set the filename from the real directory path
     $filename = $directory . basename($filename);
     // Make sure the cache directory is writable
     if (!is_dir($directory) or !is_writable($directory)) {
         throw new KoException('Cache: Directory :name is unwritable.', array(':name' => $directory));
     }
     // Make sure the cache database is writable
     if (is_file($filename) and !is_writable($filename)) {
         throw new KoException('Cache: File :name is unwritable.', array(':name' => $filename));
     }
     // Open up an instance of the database
     $this->db = new SQLiteDatabase($filename, '0666', $error);
     // Throw an exception if there's an error
     if (!empty($error)) {
         throw new KoException('Cache: Driver error - ' . sqlite_error_string($error));
     }
     $query = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'caches'";
     $tables = $this->db->query($query, SQLITE_BOTH, $error);
     // Throw an exception if there's an error
     if (!empty($error)) {
         throw new KoException('Cache: Driver error - ' . sqlite_error_string($error));
     }
     if ($tables->numRows() == 0) {
         // Issue a CREATE TABLE command
         $this->db->unbufferedQuery('CREATE TABLE caches(id VARCHAR(127) PRIMARY KEY, expiration INTEGER, cache TEXT);');
     }
 }
开发者ID:atlas1308,项目名称:testtesttestfarm,代码行数:34,代码来源:sqlite.php

示例3: __construct

 function __construct()
 {
     parent::__construct();
     $this->gallery_path = realpath(APPPATH . '../images');
     /*I also can use BASEPATH rather than APPPATH*/
     $this->gallery_path_url = base_url() . 'images/';
 }
开发者ID:koushik0004,项目名称:indiansss,代码行数:7,代码来源:gallery_model.php

示例4: entry

function entry(&$argv)
{
    if (is_file($argv[0])) {
        if (0 === substr_compare($argv[0], '.class.php', -10)) {
            $uri = realpath($argv[0]);
            if (null === ($cl = \lang\ClassLoader::getDefault()->findUri($uri))) {
                throw new \Exception('Cannot load ' . $uri . ' - not in class path');
            }
            return $cl->loadUri($uri)->literal();
        } else {
            if (0 === substr_compare($argv[0], '.xar', -4)) {
                $cl = \lang\ClassLoader::registerPath($argv[0]);
                if (!$cl->providesResource('META-INF/manifest.ini')) {
                    throw new \Exception($cl->toString() . ' does not provide a manifest');
                }
                $manifest = parse_ini_string($cl->getResource('META-INF/manifest.ini'));
                return strtr($manifest['main-class'], '.', '\\');
            } else {
                array_unshift($argv, 'eval');
                return 'xp\\runtime\\Evaluate';
            }
        }
    } else {
        return strtr($argv[0], '.', '\\');
    }
}
开发者ID:xp-runners,项目名称:main,代码行数:26,代码来源:entry.php

示例5: setupSeeds

 /**
  * Setup the seeds.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 protected function setupSeeds(Application $app)
 {
     $source = realpath(__DIR__ . '/../database/seeds/');
     if ($app instanceof LaravelApplication && $app->runningInConsole()) {
         $this->publishes([$source => database_path('seeds')], 'seeds');
     }
 }
开发者ID:jnaxo,项目名称:country-codes,代码行数:14,代码来源:CountryCodesServiceProvider.php

示例6: initialize

 /**
  * Initialize the provider
  *
  * @return void
  */
 public function initialize()
 {
     $this->options = array_merge($this->defaultConfig, $this->options);
     date_default_timezone_set($this->options['log.timezone']);
     // Finally, create a formatter
     $formatter = new LineFormatter($this->options['log.outputformat'], $this->options['log.dateformat'], false);
     // Create a new directory
     $logPath = realpath($this->app->config('bono.base.path')) . '/' . $this->options['log.path'];
     if (!is_dir($logPath)) {
         mkdir($logPath, 0755);
     }
     // Create a handler
     $stream = new StreamHandler($logPath . '/' . date($this->options['log.fileformat']) . '.log');
     // Set our formatter
     $stream->setFormatter($formatter);
     // Create LogWriter
     $logger = new LogWriter(array('name' => $this->options['log.name'], 'handlers' => array($stream), 'processors' => array(new WebProcessor())));
     // Bind our logger to Bono Container
     $this->app->container->singleton('log', function ($c) {
         $log = new Log($c['logWriter']);
         $log->setEnabled($c['settings']['log.enabled']);
         $log->setLevel($c['settings']['log.level']);
         $env = $c['environment'];
         $env['slim.log'] = $log;
         return $log;
     });
     // Set the writer
     $this->app->config('log.writer', $logger);
 }
开发者ID:krisanalfa,项目名称:b-comp,代码行数:34,代码来源:LogProvider.php

示例7: __invoke

 public function __invoke($ctx)
 {
     if (isset($ctx['Directory']['path'])) {
         $path = $ctx['Directory']['path'];
     } else {
         $url = $ctx['env']['PATH_INFO'];
         if (strpos($url, '..') !== false) {
             return array(403, array('Content-Type', 'text/plain'), 'Forbidden');
         }
         $path = $this->path . $url;
     }
     // Sanity checks
     if (!file_exists($path)) {
         return array(404, array('Content-Type', 'text/plain'), 'File not found');
     }
     $path = realpath($path);
     if (false === $path) {
         // resolving failed. not enough rights for intermediate folder?
         return array(404, array('Content-Type', 'text/plain'), 'File not found');
     }
     if (strpos($path, $this->path) !== 0) {
         // gone out of "chroot"?
         return array(404, array('Content-Type', 'text/plain'), 'File not found');
     }
     if (!is_readable($path)) {
         return array(403, array('Content-Type', 'text/plain'), 'Forbidden');
     }
     // Only files are served
     if (is_dir($path)) {
         return array(403, array('Content-Type', 'text/plain'), 'Forbidden');
     }
     return $this->serve($path);
 }
开发者ID:LookForwardPersistence,项目名称:appserver-in-php,代码行数:33,代码来源:FileServe.php

示例8: __set

 public function __set($strName, $mixValue)
 {
     switch ($strName) {
         case "HtmlIncludeFilePath":
             // Passed-in value is null -- use the "default" path name of file".tpl.php"
             if (!$mixValue) {
                 $strPath = realpath(substr(QApplication::$ScriptFilename, 0, strrpos(QApplication::$ScriptFilename, '.php')) . '.tpl.php');
             } else {
                 $strPath = realpath($mixValue);
             }
             // Verify File Exists, and if not, throw exception
             if (is_file($strPath)) {
                 $this->strHtmlIncludeFilePath = $strPath;
                 return $strPath;
             } else {
                 throw new QCallerException('Accompanying HTML Include File does not exist: "' . $mixValue . '"');
             }
             break;
         case "CssClass":
             try {
                 return $this->strCssClass = QType::Cast($mixValue, QType::String);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         default:
             try {
                 return parent::__set($strName, $mixValue);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
开发者ID:kmcelhinney,项目名称:qcodo,代码行数:34,代码来源:QFormBase.class.php

示例9: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     parent::register();
     $configPath = realpath(__DIR__ . '/../config/UEditorUpload.php');
     $this->mergeConfigFrom($configPath, 'UEditorUpload');
     $this->publishes([$configPath => config_path('UEditorUpload.php')], 'config');
 }
开发者ID:loopeer,项目名称:laravel-u-editor,代码行数:12,代码来源:UEditorServiceProvider.php

示例10: smarty_core_display_debug_console

/**
 * Smarty debug_console function plugin
 *
 * Type:     core<br>
 * Name:     display_debug_console<br>
 * Purpose:  display the javascript debug console window
 * @param array Format: null
 * @param Smarty
 */
function smarty_core_display_debug_console($params, &$smarty)
{
    // we must force compile the debug template in case the environment
    // changed between separate applications.
    if (empty($smarty->debug_tpl)) {
        // set path to debug template from SMARTY_DIR
        $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
        if ($smarty->security && is_file($smarty->debug_tpl)) {
            $smarty->secure_dir[] = realpath($smarty->debug_tpl);
        }
        $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
    }
    $_ldelim_orig = $smarty->left_delimiter;
    $_rdelim_orig = $smarty->right_delimiter;
    $smarty->left_delimiter = '{';
    $smarty->right_delimiter = '}';
    $_compile_id_orig = $smarty->_compile_id;
    $smarty->_compile_id = null;
    $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
    if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) {
        ob_start();
        $smarty->_include($_compile_path);
        $_results = ob_get_contents();
        ob_end_clean();
    } else {
        $_results = '';
    }
    $smarty->_compile_id = $_compile_id_orig;
    $smarty->left_delimiter = $_ldelim_orig;
    $smarty->right_delimiter = $_rdelim_orig;
    return $_results;
}
开发者ID:SjayLiFe,项目名称:CTRev,代码行数:41,代码来源:core.display_debug_console.php

示例11: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     self::$fixturesPath = realpath(__DIR__ . '/../Fixtures/');
     require_once self::$fixturesPath . '/includes/foo.php';
     require_once self::$fixturesPath . '/includes/ProjectExtension.php';
     require_once self::$fixturesPath . '/includes/ProjectWithXsdExtension.php';
 }
开发者ID:ABaldwinHunter,项目名称:symfony-clone,代码行数:7,代码来源:XmlFileLoaderTest.php

示例12: autoload_framework_classes

/**
 * Function used to auto load the framework classes
 * 
 * It imlements PSR-0 and PSR-4 autoloading standards
 * The required class name should be prefixed with a namespace
 * This lowercaser of the namespace should match the folder name of the class 
 * 
 * @since 1.0.0
 * @param string $class_name name of the class that needs to be included
 */
function autoload_framework_classes($class_name)
{
    error_reporting(E_ALL);
    ini_set('display_errors', true);
    ini_set('display_startup_errors', true);
    /** If the required class is in the global namespace then no need to autoload the class */
    if (strpos($class_name, "\\") === false) {
        return false;
    }
    /** The namespace seperator is replaced with directory seperator */
    $class_name = str_replace("\\", DIRECTORY_SEPARATOR, $class_name);
    /** The class name is split into namespace and short class name */
    $path_info = explode(DIRECTORY_SEPARATOR, $class_name);
    /** The namepsace is extracted */
    $namespace = implode(DIRECTORY_SEPARATOR, array_slice($path_info, 0, count($path_info) - 1));
    /** The class name is extracted */
    $class_name = $path_info[count($path_info) - 1];
    /** The namespace is converted to lower case */
    $namespace_folder = trim(strtolower($namespace), DIRECTORY_SEPARATOR);
    /** .php is added to class name */
    $class_name = $class_name . ".php";
    /** The applications folder name */
    $framework_folder_path = realpath(dirname(__FILE__));
    /** The application folder is checked for file name */
    $file_name = $framework_folder_path . DIRECTORY_SEPARATOR . $namespace_folder . DIRECTORY_SEPARATOR . $class_name;
    if (is_file($file_name)) {
        include_once $file_name;
    }
}
开发者ID:pluginscart,项目名称:Pak-PHP,代码行数:39,代码来源:autoload.php

示例13: display

 function display($tmpl_file, $app_id = null)
 {
     array_unshift($this->_files, $tmpl_file);
     $this->_vars = $this->pagedata;
     if ($p = strpos($tmpl_file, ':')) {
         $object = kernel::service('tpl_source.' . substr($tmpl_file, 0, $p));
         if ($object) {
             $tmpl_file_path = substr($tmpl_file, $p + 1);
             $last_modified = $object->last_modified($tmpl_file_path);
         }
     } else {
         $tmpl_file = realpath(APP_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file);
         $last_modified = filemtime($tmpl_file);
     }
     if (!$last_modified) {
         //无文件
     }
     $compile_id = $this->compile_id($tmpl_file);
     if ($object) {
         $compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path));
     } else {
         $compile_code = $this->_compiler()->compile_file($tmpl_file);
     }
     eval('?>' . $compile_code);
     array_shift($this->_files);
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:26,代码来源:controller.php

示例14: _initView

 protected function _initView()
 {
     // Start initail view
     $this->bootstrap('layout');
     $config = $this->getOption('views');
     $resources = $this->getOption('resources');
     $view = new Zend_View();
     if (isset($resources['layout']['layoutPath'])) {
         $view->assign('layoutRootPath', $resources['layout']['layoutPath']);
     }
     $this->bootstrap('db');
     Zend_Loader::loadClass('Ht_Utils_SystemSetting');
     $sysSetting = Ht_Utils_SystemSetting::getSettings();
     $view->assign('sysSetting', $sysSetting);
     $view->assign('profile', Zend_Auth::getInstance()->getIdentity());
     Zend_Loader::loadClass("Ht_Model_SystemSetting");
     $this->setSystemLogConfiguration($sysSetting);
     // use the viewrenderer to keep the code DRY
     // instantiate and add the helper in one go
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     $viewRenderer->setView($view);
     $viewRenderer->setViewSuffix('phtml');
     // add it to the action helper broker
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     /**
      * Set inflector for Zend_Layout
      */
     $inflector = new Zend_Filter_Inflector(':script.:suffix');
     $inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml'));
     // Initialise Zend_Layout's MVC helpers
     $this->getResource('layout')->setLayoutPath(realpath($resources['layout']['layoutPath']))->setView($view)->setContentKey('content')->setInflector($inflector);
     return $this->getResource('layout')->getView();
 }
开发者ID:kangza,项目名称:hagtag,代码行数:33,代码来源:Bootstrap.php

示例15: run_propel_build_sql_diff

function run_propel_build_sql_diff($task, $args)
{
    if (!count($args)) {
        throw new Exception('You must provide the application.');
    }
    $app = $args[0];
    if (!is_dir(sfConfig::get('sf_app_dir') . DIRECTORY_SEPARATOR . $app)) {
        throw new Exception(sprintf('The app "%s" does not exist.', $app));
    }
    run_propel_build_sql($task, $args);
    pake_echo_action('propel-sql-diff', "building database patch");
    define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../../../..'));
    define('SF_APP', $app);
    define('SF_ENVIRONMENT', isset($args[1]) ? $args[1] : 'dev');
    define('SF_DEBUG', 1);
    require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
    $databaseManager = new sfDatabaseManager();
    $databaseManager->initialize();
    $i = new dbInfo();
    $i->loadFromDb();
    $i2 = new dbInfo();
    $i2->loadAllFilesInDir(sfConfig::get('sf_data_dir') . '/sql');
    $diff = $i->getDiffWith($i2);
    $filename = sfConfig::get('sf_data_dir') . '/sql/diff.sql';
    if ($diff == '') {
        pake_echo_comment("no difference found");
    }
    pake_echo_action('propel-sql-diff', "writing file {$filename}");
    file_put_contents($filename, $diff);
}
开发者ID:sgrove,项目名称:cothinker,代码行数:30,代码来源:sfPropelSqlDiffTask.php


注:本文中的realpath函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。