Esempio n. 1
0
 public function run()
 {
     $kernel = kernel();
     $frameworkId = $kernel::FRAMEWORK_ID;
     $appId = $kernel->config->framework->ApplicationID;
     /* merge/update framework locale into app locale dir */
     $finder = Finder::create()->files()->name('*.po')->in(PH_ROOT . DIRECTORY_SEPARATOR . 'locale');
     $itr = $finder->getIterator();
     foreach ($itr as $item) {
         # echo $item->getPathname(). "\n";
         $sourceDir = dirname($item->getPathname());
         $sourceRelPath = FileUtils::remove_base($item->getPathname(), PH_ROOT);
         $sourceRelDir = dirname($sourceRelPath);
         $targetDir = PH_APP_ROOT . DIRECTORY_SEPARATOR . $sourceRelDir;
         FileUtils::mkpath($targetDir);
         $sourcePo = $sourceDir . DIRECTORY_SEPARATOR . $frameworkId . '.po';
         $targetPo = $targetDir . DIRECTORY_SEPARATOR . $appId . '.po';
         # var_dump( $sourcePo , $targetPo );
         if (file_exists($targetPo)) {
             $this->log("Msgcat " . basename($sourcePo) . ' => ' . basename($targetPo));
             $merged = '';
             $h = popen("msgcat {$sourcePo} {$targetPo}", 'r');
             while (!feof($h)) {
                 // send the current file part to the browser
                 $merged .= fread($h, 1024);
             }
             pclose($h);
             $this->log("Writing back to ");
             file_put_contents($targetPo, $merged);
         } else {
             $this->log("Copying files..");
             copy($sourcePo, $targetPo);
         }
     }
 }
Esempio n. 2
0
    public function execute()
    {
        $kernel = kernel();
        $dirs = array();
        $dirs[] = FileUtils::path_join(PH_APP_ROOT, 'cache', 'view');
        $dirs[] = FileUtils::path_join(PH_APP_ROOT, 'cache', 'config');
        $dirs[] = 'locale';
        $dirs[] = 'applications';
        $dirs[] = 'bin';
        $dirs[] = 'bundles';
        $dirs[] = 'config';
        $dirs[] = 'webroot';
        /* for hard links */
        $dirs[] = 'webroot' . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'images';
        $dirs[] = 'webroot' . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'css';
        $dirs[] = 'webroot' . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'js';
        $dirs[] = 'webroot' . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'upload';
        FileUtils::mkpath($dirs, true);
        // TODO: create .htaccess file
        $this->logger->info("Changing permissions...");
        $chmods = array();
        $chmods[] = array("og+rw", "cache");
        $chmods[] = array("og+rw", $kernel->webroot . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'upload');
        foreach ($chmods as $mod) {
            $this->logger->info("{$mod[0]} {$mod[1]}", 1);
            system("chmod -R {$mod[0]} {$mod[1]}");
        }
        $this->logger->info("Linking bin/phifty");
        if (!file_exists('bin/phifty')) {
            symlink('../phifty/bin/phifty', 'bin/phifty');
        }
        # init config
        $this->logger->info("Copying config files...");
        copy_if_not_exists(FileUtils::path_join(PH_ROOT, 'config', 'framework.app.yml'), FileUtils::path_join(PH_APP_ROOT, 'config', 'framework.yml'));
        // copy_if_not_exists(FileUtils::path_join(PH_ROOT,'config','application.dev.yml'), FileUtils::path_join(PH_APP_ROOT,'config','application.yml') );
        copy_if_not_exists(FileUtils::path_join(PH_ROOT, 'config', 'database.app.yml'), FileUtils::path_join(PH_APP_ROOT, 'config', 'database.yml'));
        copy_if_not_exists(FileUtils::path_join(PH_ROOT, 'webroot', 'index.php'), FileUtils::path_join(PH_APP_ROOT, 'webroot', 'index.php'));
        copy_if_not_exists(FileUtils::path_join(PH_ROOT, 'webroot', '.htaccess'), FileUtils::path_join(PH_APP_ROOT, 'webroot', '.htaccess'));
        $this->logger->info('Application is initialized, please edit your config files and run:');
        echo <<<DOC

    \$ bin/phifty build-conf
    \$ bin/phifty asset

    \$ lazy build-conf config/database.yml

DOC;
    }
Esempio n. 3
0
 public function execute()
 {
     $kernel = kernel();
     $dirs = array();
     $dirs[] = FileUtils::path_join(PH_APP_ROOT, 'cache', 'view');
     $dirs[] = FileUtils::path_join(PH_APP_ROOT, 'cache', 'config');
     $dirs[] = 'locale';
     $dirs[] = 'app';
     $dirs[] = 'bin';
     $dirs[] = 'bundles';
     $dirs[] = 'config';
     $dirs[] = 'webroot';
     /* for hard links */
     $dirs[] = 'webroot' . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'images';
     $dirs[] = 'webroot' . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'css';
     $dirs[] = 'webroot' . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'js';
     $dirs[] = 'webroot' . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'upload';
     $dirs[] = 'webroot' . DIRECTORY_SEPARATOR . 'upload';
     FileUtils::mkpath($dirs, true);
     // TODO: create .htaccess file
     $this->logger->info("Changing permissions...");
     $chmods = [];
     $chmods[] = ["0777", "cache"];
     $chmods[] = ["0777", "cache/view"];
     $chmods[] = ["0777", "cache/config"];
     $chmods[] = ["0777", $kernel->webroot . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'upload'];
     $chmods[] = ["0777", $kernel->webroot . DIRECTORY_SEPARATOR . 'upload'];
     foreach ($chmods as $mod) {
         $this->logger->info("Changing mode to {$mod[0]} on {$mod[1]}", 1);
         if ($this->options->system) {
             system("chmod -R {$mod[0]} {$mod[1]}");
         } else {
             chmod($mod[1], octdec($mod[0]));
         }
     }
     $this->logger->info("Creating link of bin/phifty");
     if (!file_exists('bin/phifty')) {
         symlink('../vendor/bin/phifty', 'bin/phifty');
     }
 }