將 Sencha Ext JS 整合到 PHP 應用程式中的基本元件
該庫針對使用伺服器產生的頁面從開發和生產上下文運行 Sencha Ext JS 6(即使 5 也應該工作)應用程式時的不同要求提供了簡單的抽象。開發和生產構建使用不同的來源樹來提供應用程式文件。這個過程是基於所謂的清單和 Javascript 微載入器。為了確保此過程與伺服器產生的頁面和路由無縫配合,該庫掛鉤清單產生並根據所需的環境和上下文動態修改清單。
目前,該程式庫僅用作 teqneers/ext-application-bundle 的基礎,teqneers/ext-application-bundle 是將 Ext JS 整合到基於 Symfony 的應用程式中的 Symfony 套件。我們沒有嘗試將該庫用作獨立組件或在除 Symfony 環境之外的任何其他上下文中使用,因此以下只是理論上它在沒有捆綁包的情況下應該如何工作。我們非常感謝任何幫助和貢獻,以使該庫在捆綁包之外更有用。
您可以使用composer安裝這個函式庫
composer require teqneers/ext-application
或直接將套件新增至您的composer.json 檔案。
給定一個虛構應用程式的以下目錄結構
./
|-- src/ Application source code
|-- htdocs/ Public web-facing directory (document root)
| |-- index.php PHP front controller
| |-- app/ Root folder for Ext JS application production build
|-- my-app/ The Ext JS application source folder (sencha generate app -ext MyApp ./my-app)
你應該配置你的應用程式(例如從index.php)
$ config = TQ ExtJS Application Configuration ApplicationConfiguration (
__DIR__ . ' /../my-app ' , // the absolute path to the Ext JS application workspace
' ../my-app ' , // the relative path from the public web-facing directory to the Ext JS application workspace
__DIR__ , // the absolute path to the public web-facing directory
' / ' // the relative path from the public web-facing directory to the root directory used for production build artifacts (usually /)
);
// add a default build
$ config -> addBuild (
' default ' , // the build name (just for referencing the build)
' / ' , // the application path relative to the Ext JS application workspace (usually / unless you have multiple applications and/or packages in a single workspace)
' app ' , // the application path relative to the root directory used for production build artifacts
' manifest.json ' , // the build manifest filename for development builds
' bootstrap.js ' , // the micro-loader filename for development builds
null , // the application cache manifest filename for development builds (usually NULL)
' bootstrap.json ' , // the build manifest filename for production builds
' bootstrap.js ' , // the micro-loader filename for production builds
' cache.appcache ' // the application cache manifest filename fro production builds
);
$ application = new TQ ExtJS Application Application (
$ config ,
new TQ ExtJS Application Manifest ManifestLoader (),
' dev ' // dev or prod depending on wether you want to run from development or drom production build
);
$ microLoader = $ application -> getMicroLoaderFile (); // returns a SplFileInfo for the configured micro-loader
$ hasAppCache = $ application -> hasAppCache ();
if ( $ hasAppCache ) {
$ appCache = $ application -> getAppCacheFile (); // returns a SplFileInfo for the configured application cache manifest
}
$ manifest = $ application -> getManifest ( ' /htdocs ' ); // returns a TQExtJSApplicationManifestManifest configured correctly when running document root on your application base path
echo $ manifest ; // outputs the manifest
在開發模式下執行應用程式時,您必須確保 Web 伺服器的文檔根目錄比(常規)面向公共 Web 的目錄高一級,以便 Web 伺服器也可以提供來自 Ext JS 應用程式工作區的文件。
麻省理工學院許可證 (MIT)
版權所有 (c) 2021 TEQneers GmbH & Co. KG
特此免費授予任何獲得本軟體和相關文件文件(「軟體」)副本的人不受限制地使用本軟體,包括但不限於使用、複製、修改、合併的權利、發布、分發、再授權和/或銷售軟體的副本,並允許向其提供軟體的人員這樣做,但須滿足以下條件:
上述版權聲明和本授權聲明應包含在本軟體的所有副本或主要部分中。
本軟體以「現況」提供,不提供任何明示或暗示的保證,包括但不限於適銷性、特定用途的適用性和不侵權的保證。 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE軟體.