【问题标题】:How to create a virtual host for a QCubed project in xampp on Windows?如何在 Windows 上的 xampp 中为 QCubed 项目创建虚拟主机?
【发布时间】:2016-07-06 21:55:31
【问题描述】:

在 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

【问题讨论】:

    标签: php xampp virtualhost qcubed


    【解决方案1】:

    您似乎没有定义了 Form 类的 Tef_Ticketing\Presentation\Web\Forms\Form.class.php 文件。在您的文件中,您依赖 PSR-4 Autoloader 标准:http://www.php-fig.org/psr/psr-4/。它要求命名空间/类名与文件系统文件夹结构和文件名之间有直接关系。

    【讨论】:

      【解决方案2】:

      试试

      class TestForm extends \Form {

      而不是

      class TestForm extends Form {

      【讨论】:

        猜你喜欢
        • 2019-01-15
        • 2020-06-10
        • 2016-06-10
        • 2016-05-11
        • 2015-01-31
        • 2013-10-21
        • 2012-09-05
        • 2023-03-18
        • 2011-04-26
        相关资源
        最近更新 更多