如何在Windows上的xampp中为QCubed项目创建虚拟主机


How to create a virtual host for a QCubed project in xampp on Windows?

在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

在配置公司.php

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

在家里.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]

在测试形式中.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

尝试

class TestForm extends 'Form {

而不是

class TestForm extends Form {

您似乎没有定义了 Form 类的 Tef_Ticketing''演示文稿''Web''Forms''Form.class.php 文件。在您的文件中,您依赖于PSR-4自动加载机标准:http://www.php-fig.org/psr/psr-4/。它要求在命名空间/类名与文件系统文件夹结构和文件名之间建立直接关系。