1

httpd-vhosts.conf に次を追加しました。

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/tef_ticketing/workspace/htdocs"
    ServerName tef_ticketing.dev
    ServerAlias www.tef_ticketing.dev
    <Directory "C:/xampp/htdocs/tef_ticketing/workspace/htdocs">
        DirectoryIndex home.php
        AllowOverride All
        Require all Granted
    </Directory>
</VirtualHost>

C:\Windows\System32\drivers\etc\hosts:

127.0.0.1       localhost
127.0.0.1       www.tef_ticketing.dev

configuration.inc.php で

$url = "tef_ticketing.dev";
define("__DOCROOT_URL__", $url);

home.php で

<?php
require_once (dirname(__FILE__) . '/qcubed.inc.php');
\QApplication::Redirect('test_page');

.htaccess で

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule ^$ home.php [L,QSA]
  RewriteRule ^$ ajax.php [L,QSA]
  RewriteRule ^home$ home.php [L,QSA]
  RewriteRule ^test_page$ form.php?form=TestForm [L,QSA]

TestForm.class.php 内

<?php
namespace Tef_Ticketing\Presentation\Web\Forms;
use Tef_Ticketing\Presentation\Web\Forms\Form;

class TestForm extends Form {
    protected $btnTest1;
    protected $btnTest2;
    protected $btnTest3;
    protected $lblTest1;

    protected function Form_Create() {
        parent::Form_Create();

        $this->btnTest1 = new \QButton($this);
        $this->btnTest1->Text = 'save1';
        $strJavaScript = "qc.pA('TestForm', 'btnTest2', 'QClickEvent', '', 'QFormWaitIcon');";
        $this->btnTest1->AddAction(new \QClickEvent(), new \QAjaxAction('btnTest1_click'));
        $this->btnTest1->AddAction(new \QClickEvent(), new \QJavaScriptAction($strJavaScript));

        $this->btnTest2 = new \QButton($this, 'btnTest2');
        $this->btnTest2->Text = 'save2';
        $this->btnTest2->AddAction(new \QClickEvent(), new \QAjaxAction('btnTest2_click'));

        $this->btnTest3 = new \QButton($this);
        $this->btnTest3->Text = 'save3';
        $this->btnTest3->AddAction(new \QClickEvent(), new \QAjaxAction('btnTest3_click'));

        $this->lblTest1 = new \QButton($this);
        $this->lblTest1->Text = 'init';
    }

    public function btnTest1_click() {
        sleep(5);
        $this->lblTest1->Text = 'a';
    }

    public function btnTest2_click() {
    }

    public function btnTest3_click() {
        $this->lblTest1->Refresh();
    }

}

ブラウザーで次のリンク www.tef_ticketing.dev にアクセスすると、http://www.tef_ticketing.dev/test_pageにリダイレクトされますが、問題ありません。しかし、私はエラーがあります:

Fatal error: Class 'Tef_Ticketing\Presentation\Web\Forms\Form' not found in C:\xampp\htdocs\tef_ticketing\workspace\tef_ticketing-presentation\src\Web\Forms\TestForm.class.php on line 5
4

2 に答える 2

0

Form クラスが定義された Tef_Ticketing\Presentation\Web\Forms\Form.class.php ファイルがないようです。あなたのファイルでは、PSR-4 Autoloader 標準に依存しています: http://www.php-fig.org/psr/psr-4/。名前空間/クラス名とファイルシステムのフォルダー構造およびファイル名の間に直接的な関係が必要です。

于 2016-03-23T12:21:20.097 に答える