2012-10-14 55 views
0

我正在yii框架中開發一個網站,我正在使用ext js 4 mvc結構。
我想用yii框架來使用ext js 4。
我正在使用MVC在ext js 4中獲取禁止消息。ext js MVC 403(禁止)

在這個應用程序,我得到以下消息的執行 GET http://localhost/helloext/protected/controller/Users.js?_dc=1350173045981 403(禁止)

下面是我的應用程序結構: -

helloext- 
--extjs // contins ext js 4 sdk 
--protected 
    --controllers 
    --Users.js 
--app.js 
--index.html 

代碼: -
1)的index.html

<html> 
<head> 
    <title>Account Manager</title> 

    <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css"> 

    <script type="text/javascript" src="extjs/ext-debug.js"></script> 

    <script type="text/javascript" src="app.js"></script> 
</head> 
<body></body> 
</html> 

2)app.js

Ext.application({ 
    name: 'helloext', 
    appFolder : 'protected', 

    controllers:['Users'], 

    launch: function() { 
     Ext.create('Ext.container.Viewport', { 
      layout: '', 
      items: [ 
       { 
        xtype: 'panel', 
        title: '<b>Balaee<b>', 
        html : 'List of users will go here' 
       } 
      ] 
     }); 
    } 
}); 

3)
保護
--Users.js

Ext.define('helloext.protected.controllers.Users', 
     { 
      //extend: 'Ext.app.Controller', 
     extend: 'Ext.protected.Controllers', 

     init: function() { 
      this.control({ 
       'viewport > panel': { 
        render: this.onPanelRendered 
       } 
      }); 
     }, 

     onPanelRendered: function() { 
      console.log('The panel was rendered'); 
     } 
     } 
); 

如何整合與Ext JS的4 MVC Yii框架?

+0

你有沒有檢查http://www.ext4yii.com/? – Asgaroth

回答

0

你說,「下面是我的應用程序結構」和您的應用程序結構似乎不同的東西。無論如何...

protected文件夾嚴格限制在瀏覽器中。在protected文件夾中檢查.htaccess它隱藏在窗口中),它包含deny from all。這就是爲什麼你得到403 Forbidden

1)移動Users.js以外的protected文件夾。

2)刪除.htaccess文件(但它是一個安全風險

2),或使用Yii中的assetManager。

http://www.yiiframework.com/forum/index.php?/topic/2032-assets/ http://www.yiiframework.com/wiki/148/understanding-assets/

0

我相信你需要重新設計你的ExtJS的應用與Yii框架的設計兼容。 爲了做到這一點,我會建議更換的結構如下:(又名你ExtjsApp)

/yiiApp 

     /protected 

      /assets 

       /yourExtjsApp 

您還需要使用Yii的CAssetManager發佈您的資產,使他們在全球範圍內訪問:

$assetUrl = Yii::app()->getAssetManager()->publish('application.assets', false, -1, false);

(你可以在任何地方做到這一點,我推薦views/layout/main.php或者protected/config/main。php,以便稍後訪問assetUrl)

最後在您的protected/views/layout/main.php或protected/views/index.php(無論您喜歡)中,您可以將您的Extjs應用程序創建爲如下:

Ext.application({ 
    name: 'yourExtjsApp', 
    appFolder: '<?php echo assetUrl; ?>', 
    ....