2016-04-03 157 views
2

我是stackoverflow的新成員,我對Google雲和Symphony應用程序部署有一些疑問。我已閱讀https://cloud.google.com/appengine/docs/php/symfony-hello-world的文檔,並設法部署了Hello Word應用程序,但是當我嘗試使用我的symfoy應用程序時,出現了以下錯誤: XmlFileLoader.php中的InvalidArgumentException行259:無法解析文件「(...)DependencyInjection/../Resources/config\web.xml」。 在我的app.yaml我設置了ENV變量: env_variables: GCS_BUCKET_NAME: 「pinterpandaibucket」 的cache_dir: 「GS:// pinterpandaibucket/symfony中/高速緩存」 LOG_DIR: 「GS:// pinterpandaibucket/symfony中/日誌」 我重載AppKernel.php功能:將symfony應用程序部署到Google應用程序引擎

<?php 
    public function __construct($environment = null, $debug = null) 
{ 
    // determine the environment/debug configuration based on whether or not this is running 
    // in App Engine's Dev App Server, or in production 
    if (is_null($debug)) { 
     $debug = !Environment::onAppEngine(); 
    } 

    if (is_null($environment)) { 
     $environment = $debug ? 'dev' : 'prod'; 
    } 

    parent::__construct($environment, $debug); 

    // Symfony console requires timezone to be set manually. 
    if (!ini_get('date.timezone')) { 
     date_default_timezone_set('UTC'); 
    } 

    // Enable optimistic caching for GCS. 
    $options = ['gs' => ['enable_optimsitic_cache' => true]]; 
    stream_context_set_default($options); 

    $this->gcsBucketName = getenv('GCS_BUCKET_NAME'); 

...

public function getCacheDir() 
{ 
    if ($this->gcsBucketName) { 
     return getenv('CACHE_DIR'); 
    } 

    return parent::getCacheDir(); 
} 

public function getLogDir() 
{ 
    if ($this->gcsBucketName) { 
     return getenv('LOG_DIR'); 
    } 

    return parent::getLogDir(); 
} 

public function registerContainerConfiguration(LoaderInterface $loader) 
{ 
    $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); 
} 
} 
?> 

該文件系統上寫的功能會被重定向到桶。你能幫我找到我的應用程序中缺少哪些修改。我希望這個主題能夠幫助別人,因爲Google雲文檔並不是最新的。如果我不會說英語,我會提前感謝您,並且很抱歉,我是一名法國IT學生。

奧古斯丁

+0

這可能與GCS無關,因爲您仍然可以從文件系統讀取靜態文件。該應用程序應該嘗試加載/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml。可以肯定的是,你應該在問題中包含完整的錯誤信息而不是截斷版本。你可以將你的應用程序中的這個文件與工作的symfony-starter中的文件進行比較嗎?您是否將您的應用程序從工作初級應用程序中刪除,或者嘗試以不同方式嘗試使其在App Engine上運行? – Adam

回答

1

我花了這個可怕的錯誤很多的時間,什麼我發現了這個問題發生在開發應用程序服務器,而不是在生產。我相信這是在該環境中執行xml.so php擴展的問題。

這是在symfony初學者應用程序中使用方法fixXmlFileLoaderBug修復的,該方法在web/app.php中調用。所以確保這個被調用,你應該很好去。

如果您在製作中遇到此錯誤,或者即使在調用此函數後仍然遇到此問題,請通過github上的filing an issue告知我們。

+0

非常感謝您的回答,但我最終選擇放棄Google雲平臺,並設法在亞馬遜上部署我的應用。我被困在與文件限制http://stackoverflow.com/questions/1462208/is-it-correct-that-you-are-allowed-3-000-files-per-app-engine-app-not -1-000 –

相關問題