0

我正在 yii 框架中开发一个网站,我正在使用 ext js 4 mvc 结构。
我正在尝试将 ext js 4 与 yii 框架一起使用。
我在 ext js 4 中使用 MVC,我收到禁止消息。

在执行此应用程序期间,我收到以下消息 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');
        }
        }
);

我如何将 yii 框架与 ext js 4 mvc 集成?

4

2 回答 2

0

你说,“下面是我的应用程序结构”,你的应用程序结构似乎有些不同。反正...

protected文件夹严格限制在浏览器中。检查文件夹内的.htaccess它隐藏在 Windows 中)文件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/

于 2012-10-15T10:52:49.647 回答
0

我相信你需要重新设计你的 Extjs 应用程序以兼容 Yii 框架的设计。为此,我推荐以下结构:

/yiiApp

      /protected

          /assets

              /yourExtjsApp

你还需要使用 Yii CAssetManager 来发布你的资产(也就是你的 ExtjsApp),这样它们就可以在全球范围内访问:

$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; ?>',
    ....
于 2013-06-15T15:10:03.043 回答