Ext js MVC 403(Forbidden)

时间:2012-10-14 11:33:46

标签: php extjs yii

我正在yii框架中开发一个网站,我正在使用ext js 4 mvc结构 我试图在yii框架中使用ext js 4 我在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集成?

2 个答案:

答案 0 :(得分:0)

您说,“ 以下是我的应用程序结构 ”,您的应用程序结构似乎有所不同。反正...

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

答案 1 :(得分: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; ?>',
    ....
相关问题