当我访问http://192.168.0.146/test/显示的是正常页面
当我访问http://192.168.0.146/test/manage
显示**Test\Frontend\Controllers\ManageController handler class cannot be loaded**
我需要执行Test\Manage\Controllers\IndexController 还需要如何处理?
项目创建过程如下
phalcon project test modules --enable-webtools
Phalcon DevTools (2.0.7)
Success: Controller "index" was successfully created.
Success: Project "test" was successfully created.
复制app/frontend-》app/manage
修改app/manage/controllers下程序的namespace 为Test\Manage\Controllers;
修改app/manage/Module.php
<?php namespace Test\Manage; use Phalcon\DiInterface; use Phalcon\Loader; use Phalcon\Mvc\View; use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; use Phalcon\Mvc\ModuleDefinitionInterface; class Module implements ModuleDefinitionInterface { /** * Registers an autoloader related to the module * * @param DiInterface $di */ public function registerAutoloaders(DiInterface $di = null) { $loader = new Loader(); $loader->registerNamespaces(array( 'Test\Manage\Controllers' => __DIR__ . '/controllers/', 'Test\Manage\Models' => __DIR__ . '/models/', )); $loader->register(); } /** * Registers services related to the module * * @param DiInterface $di */ public function registerServices(DiInterface $di) { /** * Read configuration */ $config = include APP_PATH . "/apps/manage/config/config.php"; /** * Setting up the view component */ $di['view'] = function () { $view = new View(); $view->setViewsDir(__DIR__ . '/views/'); return $view; }; /** * Database connection is created based in the parameters defined in the configuration file */ $di['db'] = function () use ($config) { return new DbAdapter($config->toArray()); }; } }
修改test/config/modules.php
<?php /** * Register application modules */ $application->registerModules(array( 'frontend' => array( 'className' => 'Test\Frontend\Module', 'path' => __DIR__ . '/../apps/frontend/Module.php' ), 'manage' => array( 'className' => 'Test\Manage\Module', 'path' => __DIR__ . '/../apps/manage/Module.php' ) ));
test/config/services.php未修改
<?php /** * Services are globally registered in this file * * @var \Phalcon\Config $config */ use Phalcon\Mvc\Router; use Phalcon\Mvc\Url as UrlResolver; use Phalcon\Di\FactoryDefault; use Phalcon\Session\Adapter\Files as SessionAdapter; use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; use Phalcon\Mvc\Model\Metadata\Memory as MetaDataAdapter; use Phalcon\Mvc\View; use Phalcon\Mvc\View\Engine\Volt as VoltEngine; /** * The FactoryDefault Dependency Injector automatically registers the right services to provide a full stack framework */ $di = new FactoryDefault(); /** * Registering a router */ $di->set('router', function () { $router = new Router(); $router->setDefaultModule('frontend'); $router->setDefaultNamespace('Test\Frontend\Controllers'); return $router; }); /** * The URL component is used to generate all kinds of URLs in the application */ $di->set('url', function () { $url = new UrlResolver(); $url->setBaseUri('/test/'); return $url; }); /** * Setting up the view component */ $di->setShared('view', function () use ($config) { $view = new View(); $view->setViewsDir($config->application->viewsDir); $view->registerEngines(array( '.volt' => function ($view, $di) use ($config) { $volt = new VoltEngine($view, $di); $volt->setOptions(array( 'compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_' )); return $volt; }, '.phtml' => 'Phalcon\Mvc\View\Engine\Php' )); return $view; }); /** * Database connection is created based in the parameters defined in the configuration file */ $di->set('db', function () use ($config) { return new DbAdapter($config->database->toArray()); }); /** * If the configuration specify the use of metadata adapter use it or use memory otherwise */ $di->set('modelsMetadata', function () { return new MetaDataAdapter(); }); /** * Starts the session the first time some component requests the session service */ $di->setShared('session', function () { $session = new SessionAdapter(); $session->start(); return $session; }); /** * Set the default namespace for dispatcher */ $di->setShared('dispatcher', function() use ($di) { $dispatcher = new Phalcon\Mvc\Dispatcher(); $dispatcher->setDefaultNamespace('Test\Frontend\Controllers'); return $dispatcher; });
test/config/routes.php
<?php $router = $di->get("router"); foreach ($application->getModules() as $key => $module) { $namespace = str_replace('Module','Controllers', $module["className"]); $router->add('/'.$key.'/:params', array( 'namespace' => $namespace, 'module' => $key, 'controller' => 'index', 'action' => 'index', 'params' => 1 ))->setName($key); $router->add('/'.$key.'/:controller/:params', array( 'namespace' => $namespace, 'module' => $key, 'controller' => 1, 'action' => 'index', 'params' => 2 )); $router->add('/'.$key.'/:controller/:action/:params', array( 'namespace' => $namespace, 'module' => $key, 'controller' => 1, 'action' => 2, 'params' => 3 )); }
public/index.php
<?php use Phalcon\Mvc\Application; error_reporting(E_ALL); define('APP_PATH', realpath('..')); try { /** * Read the configuration */ $config = include APP_PATH . "/apps/frontend/config/config.php"; /** * Include services */ require __DIR__ . '/../config/services.php'; /** * Handle the request */ $application = new Application($di); /** * Include modules */ require __DIR__ . '/../config/modules.php'; /** * Include routes */ require __DIR__ . '/../config/routes.php'; echo $application->handle()->getContent(); } catch (Exception $e) { echo $e->getMessage(); }
回复内容:
当我访问http://192.168.0.146/test/显示的是正常页面
当我访问http://192.168.0.146/test/manage
显示**Test\Frontend\Controllers\ManageController handler class cannot be loaded**
我需要执行Test\Manage\Controllers\IndexController 还需要如何处理?
项目创建过程如下
phalcon project test modules --enable-webtools
Phalcon DevTools (2.0.7)
Success: Controller "index" was successfully created.
Success: Project "test" was successfully created.
复制app/frontend-》app/manage
修改app/manage/controllers下程序的namespace 为Test\Manage\Controllers;
修改app/manage/Module.php
<?php namespace Test\Manage; use Phalcon\DiInterface; use Phalcon\Loader; use Phalcon\Mvc\View; use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; use Phalcon\Mvc\ModuleDefinitionInterface; class Module implements ModuleDefinitionInterface { /** * Registers an autoloader related to the module * * @param DiInterface $di */ public function registerAutoloaders(DiInterface $di = null) { $loader = new Loader(); $loader->registerNamespaces(array( 'Test\Manage\Controllers' => __DIR__ . '/controllers/', 'Test\Manage\Models' => __DIR__ . '/models/', )); $loader->register(); } /** * Registers services related to the module * * @param DiInterface $di */ public function registerServices(DiInterface $di) { /** * Read configuration */ $config = include APP_PATH . "/apps/manage/config/config.php"; /** * Setting up the view component */ $di['view'] = function () { $view = new View(); $view->setViewsDir(__DIR__ . '/views/'); return $view; }; /** * Database connection is created based in the parameters defined in the configuration file */ $di['db'] = function () use ($config) { return new DbAdapter($config->toArray()); }; } }
修改test/config/modules.php
<?php /** * Register application modules */ $application->registerModules(array( 'frontend' => array( 'className' => 'Test\Frontend\Module', 'path' => __DIR__ . '/../apps/frontend/Module.php' ), 'manage' => array( 'className' => 'Test\Manage\Module', 'path' => __DIR__ . '/../apps/manage/Module.php' ) ));
test/config/services.php未修改
<?php /** * Services are globally registered in this file * * @var \Phalcon\Config $config */ use Phalcon\Mvc\Router; use Phalcon\Mvc\Url as UrlResolver; use Phalcon\Di\FactoryDefault; use Phalcon\Session\Adapter\Files as SessionAdapter; use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; use Phalcon\Mvc\Model\Metadata\Memory as MetaDataAdapter; use Phalcon\Mvc\View; use Phalcon\Mvc\View\Engine\Volt as VoltEngine; /** * The FactoryDefault Dependency Injector automatically registers the right services to provide a full stack framework */ $di = new FactoryDefault(); /** * Registering a router */ $di->set('router', function () { $router = new Router(); $router->setDefaultModule('frontend'); $router->setDefaultNamespace('Test\Frontend\Controllers'); return $router; }); /** * The URL component is used to generate all kinds of URLs in the application */ $di->set('url', function () { $url = new UrlResolver(); $url->setBaseUri('/test/'); return $url; }); /** * Setting up the view component */ $di->setShared('view', function () use ($config) { $view = new View(); $view->setViewsDir($config->application->viewsDir); $view->registerEngines(array( '.volt' => function ($view, $di) use ($config) { $volt = new VoltEngine($view, $di); $volt->setOptions(array( 'compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_' )); return $volt; }, '.phtml' => 'Phalcon\Mvc\View\Engine\Php' )); return $view; }); /** * Database connection is created based in the parameters defined in the configuration file */ $di->set('db', function () use ($config) { return new DbAdapter($config->database->toArray()); }); /** * If the configuration specify the use of metadata adapter use it or use memory otherwise */ $di->set('modelsMetadata', function () { return new MetaDataAdapter(); }); /** * Starts the session the first time some component requests the session service */ $di->setShared('session', function () { $session = new SessionAdapter(); $session->start(); return $session; }); /** * Set the default namespace for dispatcher */ $di->setShared('dispatcher', function() use ($di) { $dispatcher = new Phalcon\Mvc\Dispatcher(); $dispatcher->setDefaultNamespace('Test\Frontend\Controllers'); return $dispatcher; });
test/config/routes.php
<?php $router = $di->get("router"); foreach ($application->getModules() as $key => $module) { $namespace = str_replace('Module','Controllers', $module["className"]); $router->add('/'.$key.'/:params', array( 'namespace' => $namespace, 'module' => $key, 'controller' => 'index', 'action' => 'index', 'params' => 1 ))->setName($key); $router->add('/'.$key.'/:controller/:params', array( 'namespace' => $namespace, 'module' => $key, 'controller' => 1, 'action' => 'index', 'params' => 2 )); $router->add('/'.$key.'/:controller/:action/:params', array( 'namespace' => $namespace, 'module' => $key, 'controller' => 1, 'action' => 2, 'params' => 3 )); }
public/index.php
<?php use Phalcon\Mvc\Application; error_reporting(E_ALL); define('APP_PATH', realpath('..')); try { /** * Read the configuration */ $config = include APP_PATH . "/apps/frontend/config/config.php"; /** * Include services */ require __DIR__ . '/../config/services.php'; /** * Handle the request */ $application = new Application($di); /** * Include modules */ require __DIR__ . '/../config/modules.php'; /** * Include routes */ require __DIR__ . '/../config/routes.php'; echo $application->handle()->getContent(); } catch (Exception $e) { echo $e->getMessage(); }
pbulic/index.php
require DIR . '/../config/routes.php';下面
加上$di->set('router',$router);
<?php use Phalcon\Mvc\Application; error_reporting(E_ALL); define('APP_PATH', realpath('..')); try { /** * Read the configuration */ $config = include APP_PATH . "/apps/manage/config/config.php"; /** * Include services */ require __DIR__ . '/../config/services.php'; /** * Handle the request */ $application = new Application($di); /** * Include modules */ require __DIR__ . '/../config/modules.php'; /** * Include routes */ require __DIR__ . '/../config/routes.php'; $di->set('router',$router); echo $application->handle()->getContent(); } catch (Exception $e) { echo $e->getMessage(); }
题主给的信息不够,多模块设置里有几个比较重要的东西都不给出来,比如:routes.php 和 各个模块里的 Module.php,这两个都关系到多模块的加载。

PHPでは、特性は方法が必要な状況に適していますが、継承には適していません。 1)特性により、クラスの多重化方法が複数の継承の複雑さを回避できます。 2)特性を使用する場合、メソッドの競合に注意を払う必要があります。メソッドの競合は、代替およびキーワードとして解決できます。 3)パフォーマンスを最適化し、コードメンテナビリティを改善するために、特性の過剰使用を避け、その単一の責任を維持する必要があります。

依存関係噴射コンテナ(DIC)は、PHPプロジェクトで使用するオブジェクト依存関係を管理および提供するツールです。 DICの主な利点には、次のものが含まれます。1。デカップリング、コンポーネントの独立したもの、およびコードの保守とテストが簡単です。 2。柔軟性、依存関係を交換または変更しやすい。 3.テスト可能性、単体テストのために模擬オブジェクトを注入するのに便利です。

SplfixedArrayは、PHPの固定サイズの配列であり、高性能と低いメモリの使用が必要なシナリオに適しています。 1)動的調整によって引き起こされるオーバーヘッドを回避するために、作成時にサイズを指定する必要があります。 2)C言語アレイに基づいて、メモリと高速アクセス速度を直接動作させます。 3)大規模なデータ処理とメモリに敏感な環境に適していますが、サイズが固定されているため、注意して使用する必要があります。

PHPは、$ \ _ファイル変数を介してファイルのアップロードを処理します。セキュリティを確保するための方法には次のものが含まれます。1。アップロードエラー、2。ファイルの種類とサイズを確認する、3。ファイル上書きを防ぐ、4。ファイルを永続的なストレージの場所に移動します。

JavaScriptでは、nullcoalescingoperator(??)およびnullcoalescingsignmentoperator(?? =)を使用できます。 1.??最初の非潜水金または非未定されたオペランドを返します。 2.??これらの演算子は、コードロジックを簡素化し、読みやすさとパフォーマンスを向上させます。

XSS攻撃を防ぎ、リソースのロードを制限し、ウェブサイトのセキュリティを改善できるため、CSPは重要です。 1.CSPはHTTP応答ヘッダーの一部であり、厳格なポリシーを通じて悪意のある行動を制限します。 2。基本的な使用法は、同じ起源からのロードリソースのみを許可することです。 3.高度な使用法は、特定のドメイン名がスクリプトやスタイルをロードできるようにするなど、より微調整された戦略を設定できます。 4。CSPポリシーをデバッグおよび最適化するには、コンテンツセキュリティポリシーレポートのみのヘッダーを使用します。

HTTPリクエストメソッドには、それぞれリソースを取得、送信、更新、削除するために使用されるGET、POST、PUT、および削除が含まれます。 1. GETメソッドは、リソースを取得するために使用され、読み取り操作に適しています。 2. POSTメソッドはデータの送信に使用され、新しいリソースを作成するためによく使用されます。 3. PUTメソッドは、リソースの更新に使用され、完全な更新に適しています。 4.削除メソッドは、リソースの削除に使用され、削除操作に適しています。

HTTPSは、HTTPに基づいてセキュリティレイヤーを追加するプロトコルであり、主に暗号化されたデータを介してユーザーのプライバシーとデータセキュリティを保護します。その作業原則には、TLSの握手、証明書の確認、暗号化された通信が含まれます。 HTTPSを実装する場合、証明書管理、パフォーマンスへの影響、および混合コンテンツの問題に注意を払う必要があります。


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

SecLists
SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。

メモ帳++7.3.1
使いやすく無料のコードエディター

ドリームウィーバー CS6
ビジュアル Web 開発ツール

AtomエディタMac版ダウンロード
最も人気のあるオープンソースエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ホットトピック



