2016-09-09 20 views
2

部署Yii2事前申請通過引用this此鏈接我已經成功地包裝我的簡單的PHP應用程序。現在我想整個Yii2 Advance應用程序打包(創建.phar文件)以將其部署到服務器上。包裝和使用藥業

我跟着上面的鏈接中給出的所有步驟,但是當我運行它給我這個錯誤:

Warning: require(phar://D:/www/myphartest.phar/../../vendor/autoload.php): failed to open stream: phar error: "vendor/autoload.php" is not a file in phar "D:/www/myphartest.phar" in phar://D:/www/myphartest.phar/index.php on line 5 

Fatal error: require(): Failed opening required 'phar://D:/www/myphartest.phar/../../vendor/autoload.php' (include_path='phar://D:\www\myphartest.phar;.;C:\php\pear') in phar://D:/www/myphartest.phar/index.php on line 5 

以下是我的結構:

d:\ WWW \ myphartest

  • 版本(目錄)

    • 的config.ini
    • myphartest.phar
  • SRC(目錄)

    • [在src =>我yii2預先應用文件和文件夾]
  • 創建-phar.php(文件)

這裏是我的config.ini文件(編譯& WWW目錄內)

[database] 
host=localhost 
db=mydb 
user=root 
pass=root 

有我的src目錄裏面添加的index.php

<?php 
require_once "phar://myphartest.phar/backend/web"; 
$config = parse_ini_file("config.ini"); 
AppManager::run($config); 

run.php(內部WWW)

<?php 
require "myphartest.phar"; 

任何幫助,將不勝感激。

回答

2

我會建議使用box創建藥業的。它只是工作:),並有其他功能,如果你喜歡。

它可以在3個簡單的步驟來使用:

  • 下載box.phar,看到box readme
  • 創建配置文件box.json,見下面的例子
  • 運行php box.phar build --verbose(詳細見文件的列表進入你的phar)

配置示例:

{ 
    "alias": "main.phar", 
    "chmod": "0755", 
    "directories": [ 
     "src" 
    ], 
    "files": [ 
     "README.md", 
     "LICENSE" 
    ], 
    "finder": [ 
     { 
      "name": "*.php", 
      "exclude": [ 
       "tests", 
       "Tests" 
      ], 
      "in": "vendor" 
     } 
    ], 
    "git-version": "package_version", 
    "main": "bin/main.php", 
    "output": "main.phar", 
    "stub": true 
} 

,甚至可以把大部分的選項了。剛剛離開mainoutputfiles一個,directoriesfinder爲箱體知道該把裏面你藥業的東西。

我試過用基於Yii2的控制檯程序 - 工作正常!

+0

獲取錯誤:'C:\> curl -LSs https://box-project.github.io/box2/installer.php | curl:(7)失敗連接到box-project.github.io:443;沒有錯誤' – Sky

+0

文件是可下載的。我認爲你的問題是因爲s​​sl證書。試試cul -kLSs ... - 'k'跳過證書檢查。 – hiqsol