我正在尝试运行Phalcon应用程序。获取此IndexController处理程序类错误。这是我的控制器。
define('PHALCONSTART', microtime(true));
define('PROJECT_PATH', dirname(dirname(__FILE__)) . '/');
use Phalcon\Mvc\Application,
Phalcon\Loader;
date_default_timezone_set('Europe/Dublin');
require_once PROJECT_PATH . 'apps/bootstrap.php';
$loader = new Loader();
$loader->registerNamespaces([
'Apps\Commons\Models' => PROJECT_PATH . 'apps/commons/models/',
'Library' => PROJECT_PATH . 'library/'
]);
$loader->registerClasses([
'Apps\Commons\AbstractModule' => PROJECT_PATH . 'apps/commons/AbstractModule.php',
]);
$loader->register();
/**
* Include services
*/
require PROJECT_PATH . 'config/services.php';
require PROJECT_PATH . 'config/repos.php';
/**
* Handle the request
*/
$application = new Application();
/**
* Assign the DI
*
* @var Phalcon\DI\FactoryDefault $di
*/
$application->setDI($di);
//$application->useImplicitView(false);
/**
* Register application modules
*/
$modules = [];
foreach ($config->modules as $index => $modul)
{
$modules[$index] = [
'className' => $modul->className,
'path' => $modul->dir . 'Module.php'
];
}
$application->registerModules($modules);
require PROJECT_PATH . 'config/function.php';
$response = $application->handle();
$response->send();
无论我做什么,都会遇到此错误。在任何地方都找不到解决方案。我附上了遇到的错误的屏幕截图。
致命错误:未捕获的Phalcon \ Mvc \ Dispatcher \ Exception:Apps \ Members \ Controllers \ IndexController处理程序类无法加载到C:\ xampp7126 \ htdocs \ find-us-local \ public \ index.php:86堆栈跟踪:#0 [内部函数]:Phalcon \ Mvc \ Dispatcher-> _ throwDispatchException('Apps \ Members \ Co ...',2)#1 [内部函数]:Phalcon \ Dispatcher-> dispatch()#2 C:\ xampp7126 \ htdocs \ find-us-local \ public \ index.php(86):Phalcon \ Mvc \ Application-> handle()#3 {main}抛出C:\ xampp7126 \ htdocs \ find-us-local \ public \ index.php在第86行
已更新:已添加控制器源代码
以下是控制器源代码
namespace Members\Controller;
use Members\Form\Profile;
use Phalcon\Mvc\Dispatcher;
use User\Model\Content;
use User\Model\SubscriptionItems;
use User\Model\Subscriptions;
use User\Model\Support\SupportticketFollowups;
use User\Model\Users;
use Phalcon\Mvc\View;
use User\Model\UsersNotifications;
use User\Model\Usersocialnetworks;
use User\Model\UsersTraffic;
use User\Model\AuthnetTransactions;
use Hybridauth\Hybridauth;
use Phalcon\Mvc\Model\Exception;
use User\Model\Payments\Paypal\PaypalRecurringTrans;
use User\Model\Support\SupportTickets;
use Apps\Members\Controllers\BaseController;
class IndexController extends BaseController
{
public function initialize()
{
parent::initialize(); // TODO: Change the autogenerated stub
if (!$this->user)
{
die();
return $this->response->redirect(['for' => 'oauth.auth.action', 'action' => 'login'])->send();
}
}
/**
* @return View\Engine\Php
*/
public function indexAction()
{
$one_day_traffic = UsersTraffic::sum([
'column' => 'hits',
'conditions' => 'userid = :userid: AND date >= :date:',
'bind' => ['userid' => $this->user_id, 'date' => date('Y-m-d', strtotime('-1 days'))]
]);
$seven_day_traffic = UsersTraffic::sum([
'column' => 'hits',
'conditions' => 'userid = :userid: AND date >= :date:',
'bind' => ['userid' => $this->user_id, 'date' => date('Y-m-d', strtotime('-7 days'))]
]);
$thirty_day_traffic = UsersTraffic::sum([
'column' => 'hits',
'conditions' => 'userid = :userid: AND date >= :date:',
'bind' => ['userid' => $this->user_id, 'date' => date('Y-m-d', strtotime('-30 days'))]
]);
$phql =
'SELECT date, sum(hits) as sum_hits FROM \User\Model\UsersTraffic WHERE userid = :userid: AND date >= :date: GROUP BY date';
$query = $this->modelsManager->createQuery($phql);
$sums_hits = $query->execute(['userid' => $this->user_id, 'date' => date('Y-m-d', strtotime('-30 days'))]);
$_max = 0;
$_min = 0;
foreach ($sums_hits as $sum)
{
if ($_max == 0 AND $_min == 0)
{
$_max = $sum->sum_hits;
$_min = $sum->sum_hits;
} else
{
if ($_max < $sum->sum_hits)
{
$_max = $sum->sum_hits;
}
if ($_min > $sum->sum_hits)
{
$_min = $sum->sum_hits;
}
}
}
$day_traffic_30_min = $_min;
$day_traffic_30_max = $_max;
$this->assets->collection('header')
->addJs('/javascript/alljs.js', false)
->addJs('/javascript/tooltip.js', false)
->addJs('https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', false, false)
->addJs('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js', false, false);
$this->view->setVars(compact('one_day_traffic', 'seven_day_traffic', 'thirty_day_traffic', 'day_traffic_30_min', 'day_traffic_30_max'));
}
public function dit_basic_infoAction()
{
}
/**
* @return View
*/
public function membersSocialAction()
{
$go = $this->request->getPost('go');
if (!empty('go') && $go == 'socialpost')
{
$post_title = $this->request->getPost('post_title', 'string');
$post_message = $this->request->getPost('post_message', 'striptags');
$post_networks = $this->request->getPost('post_networks', null, []);
/*if (!empty($post_title) && !empty($post_message) && is_array($post_networks))
{
// Set a session variable
$this->session->set("socualposts", compact('post_title', 'post_message', 'post_networks'));
// Get first record
$usersocialnetworks = Usersocialnetworks::findFirst($this->filter->sanitize($post_networks[0]), 'int');
if(!empty($usersocialnetworks))
{
return $this->response->redirect(['for' => 'oauth.hybridauth.index', 'provider' => $usersocialnetworks->network]);
}
}*/
}
$usersocialnetworks = $this->user->ManySocialnetworks;
$this->view->setVars(compact('usersocialnetworks'));
}
/**
* @return string
*/
public function profile_statsgraphAction()
{
//Disable the view
$this->view->disable();
$userid = $this->request->get('userid', 'int');
$content_id = $this->request->get('content_id', 'int');
$category_id = $this->request->get('category_id', 'int');
$parentcategory_id = $this->request->get('parentcategory_id', 'int');
return $this->view->getPartial("members/index/profile_statsgraph",
compact('userid', 'content_id', 'category_id', 'parentcategory_id'));
}
/**
* View all Businesses fro user
*
* @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
*/
public function businessesAction()
{
$go = $this->request->get('go');
$id = $this->request->get('id', 'int', null);
// If delete content
if (!empty($go) && $go == 'unclaim' && !empty($id))
{
// Get content via ID
$content = Content::findFirst($id);
// If not found record
if (!$content)
{
$this->flashSession->error('There is no such record in the database!');
goto endgo;
}
// If this record does not belong to this user
if ($content->userid != $this->user_id)
{
$this->flashSession->error('You can not delete this record! You do not have the rights!');
goto endgo;
}
if (!$content->update([
'userid' => 0,
'profileid' => 0,
'plan_id' => 0,
'rating' => 0,
'views' => 0,
'ratingwidth' => 0,
'featured' => 0,
'owner_email' => '',
'owner_name' => '',
'owner_title' => ''
])
)
{
if (APPLICATION_ENV == 'development')
{
foreach ($content->getMessages() as $message)
{
$this->flashSession->error($message . ', ');
}
goto endgo;
}
$this->flashSession->error('An error occurred while deleting. Try again later or contact the administrator!');
goto endgo;
} else
{
// Set notification for users_notifications table
$users_notification = new UsersNotifications();
$users_notification->userid = $this->user_id;
$users_notification->notification_type = 'profile_management';
$users_notification->notification_subject = 'Profile Unclaimed';
$users_notification->notification_body =
'You have unclaimed a profile: ' . $content->company . ' <Br>' . $content->full_address;
$users_notification->support_enabled = 1;
$users_notification->support_ticketid = 0;
if ($users_notification->save() == false)
{
if (APPLICATION_ENV == 'development')
{
$this->logger->error('Error to handle: ' . implode(', ', $users_notification->getMessages()));
}
}
}
$this->flashSession->success('You deleted this item!');
endgo:
return $this->response->redirect(['for' => 'members.action', 'action' => 'businesses']);
}
end:
$contents = Content::findByUserid($this->user_id);
$this->assets->collection('header')
->addJs('/javascript/tooltip.js', false)
->addJs('https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', false, false)
->addJs('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js', false, false)
->addJs('/javascript/alljs.js', false);
$user_id = $this->user_id;
$this->view->setVars(compact('contents', 'user_id'));
}
/**
* Return script for Business Profile Stats of /members/index page
*
* @return string
*/
public function statsgraphAction()
{
//Disable the view
$this->view->setRenderLevel(
View::LEVEL_ACTION_VIEW
);
$count_day = 20;
$userid = $this->request->get('userid', 'int');
$rndval = $this->request->get('rndval', 'int');
$hits_traffic = UsersTraffic::find([
'userid = :userid: AND date >= :date:',
'bind' => ['userid' => $userid, 'date' => date('Y-m-d', strtotime('-' . $count_day . ' days'))],
]);
$hit_sums_by_date = [];
$call_sums_by_date = [];
$months = [];
$days = [];
for ($day = $count_day; $day >= 0; $day--)
{
$date = date('Y-m-d', strtotime('-' . $day . ' days'));
$months[date('Y-m', strtotime('-' . $day . ' days'))] = date('F Y', strtotime('-' . $day . ' days'));
$hit_sums_by_date[$date] = 0;
$call_sums_by_date[$date] = 0;
$days[$date] = (int)date('j', strtotime('-' . $day . ' days'));
}
reset($months);
$title_text = current($months);
if (count($months) > 1)
{
$title_text .= ' - ' . end($months);
}
$days = implode(',', $days);
foreach ($hits_traffic as $item)
{
$hit_sums_by_date[$item->date] += $item->hits;
$hit_sums_by_date[$item->date] += $item->mobilehits;
$call_sums_by_date[$item->date] += $item->mobilecalls;
$call_sums_by_date[$item->date] += $item->calls;
}
$visitors_sums = implode(',', $hit_sums_by_date);
$calls_sums = implode(',', $call_sums_by_date);
$this->view->visitors_sums = $visitors_sums;
$this->view->calls_sums = $calls_sums;
$this->view->title_text = $title_text;
$this->view->days = $days;
}
/**
* Change User Profile page
*/
public function profileAction()
{
$user = Users::findFirst($this->user_id);
$user->confirm_email = $this->user->email;
$post_data = $this->request->getPost();
/**
* @var Profile form
*/
$form = new Profile($user);
if ($this->request->isPost())
{
// If edit profile
if (!empty($post_data['go']) && $post_data['go'] == 'EDIT')
{
if ($this->security->checkToken())
{
if ($form->isValid($post_data))
{
if (!empty($post_data['new_password']))
{
$user->password = $this->security->hash($post_data['new_password']);
}
if ($user->save() == false)
{
if (APPLICATION_ENV == 'development')
{
foreach ($user->getMessages() as $message)
{
$this->flashSession->error($message . ', ');
}
} else
{
$this->flashSession->error('An error occurred while saving! Please try again later or contact the administrator!');
}
} else
{
$this->flashSession->success('You have successfully changed your profile!');
}
}
} else
{
$this->flashSession->error('CSRF validation failed');
}
// edit image for profile
} elseif (!empty($post_data['go']) && $post_data['go'] == 'upload_image')
{
if ($this->request->hasFiles() == true)
{
$baseLocation = PUBLIC_PATH . '/userprofile_images/';
// Check directory
if (!file_exists($baseLocation))
{
mkdir($baseLocation, 0777);
}
// Print the real file names and sizes
foreach ($this->request->getUploadedFiles() as $file)
{
if (in_array($file->getExtension(), ['jpg', 'gif', 'png', 'jpeg']))
{
if ($file->getSize() < 50000)
{
$name_file = time() . $this->filter->sanitize($file->getName(), 'string');
// delete old images
if (file_exists($baseLocation . $user->profile_image))
{
unlink($baseLocation . $user->profile_image);
}
//$user->profile_image = $prev_name . $file->getName();
if ($user->update(['profile_image' => $name_file]))
{
//Move the file into the application
$file->moveTo($baseLocation . $name_file);
$image = new \Phalcon\Image\Adapter\Gd($baseLocation . $name_file);
$image->resize(
139,
null,
\Phalcon\Image::WIDTH
);
$width = 139;
$height = 139;
$offsetX = (($image->getWidth() - $width) / 2);
$offsetY = (($image->getHeight() - $height) / 2);
$image->crop($width, $height, $offsetX, $offsetY);
$image->save($baseLocation . $name_file);
$this->flashSession->success('You have successfully changed your profile image!');
} else
{
$this->flashSession->error('An error occurred while saving! Please try again later or contact the administrator!');
}
} else
{
$this->flashSession->error('The file must not exceed 500 kb');
}
} else
{
$this->flashSession->error('The file must be the following format - jpg/gif/png');
}
}
}
}
}
$this->assets->collection('header')
->addJs('/javascript/tooltip.js', false)
->addJs('https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', false, false)
->addJs('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js', false, false);
$this->view->setVars(compact('form'));
}
/**
* @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface|string
*/
public function billingAction()
{
$order_item_id = $this->request->get('order_item_id', 'int');
$get_trans = $this->request->get('get_trans', 'int');
$rndval = $this->request->get('rndval', 'int');
$go = $this->request->get('go');
if (!empty($order_item_id))
{
//Disable the view
$this->view->disable();
$subscriptions = Subscriptions::findFirst(['order_item_id=:order_item_id:', 'bind' => ['order_item_id' => $order_item_id]]);
if (!empty($go) && $go == 'cancel_subscr')
{
if (!empty($subscriptions) && $subscriptions->update(['an_status' => 'cancelled']))
{
$this->flashSession->success('You have closed a plan!');
} else
{
if (APPLICATION_ENV == 'development')
{
foreach ($subscriptions->getMessages() as $message)
{
$this->flashSession->error($message . ', ');
}
} else
{
$this->flashSession->error('An error occurred while closing this plan');
}
}
return $this->response->redirect(['for' => 'members.action', 'action' => 'billing']);
} elseif (!empty($get_trans) && !empty($rndval))
{
if ($subscriptions)
{
$authnet_transactions = [];
$paypal_transactions = [];
if ($subscriptions->pmt_src == 'paypal')
{
$paypal_transactions = PaypalRecurringTrans::find(['recurring_payment_id=:PP_PROFILEID:', 'bind' => ['PP_PROFILEID' => $subscriptions->PP_PROFILEID]]);
} elseif ($subscriptions->pmt_src == 'authnet')
{
$authnet_transactions = AuthnetTransactions::find(['x_subscription_id=:x_subscription_id:', 'bind' => ['x_subscription_id' => $subscriptions->an_subscr_id]]);
}
return $this->view->getPartial('members/billing/get_order', compact('subscriptions', 'paypal_transactions', 'authnet_transactions'));
}
}
}
$this->assets->collection('header')
->addJs('/javascript/alljs.js', false)
->addJs('/javascript/tooltip.js', false);
}
/**
* @return View
*/
public function upgradeAction()
{
$this->assets->collection('header')
->addCss('/css/profile-ful.css', false);
$add_product_id = $this->request->get('add_product_id', 'striptags', null);
if (is_null($add_product_id))
{
// Get content via ID
$content = Content::findFirstByProfileid($this->user_id);
$add_product_id = 'local_dir_premium:' . $content->parentcategory_id . ':' . $content->category_id . ':' . $content->id;
}
$this->view->setVars(compact('add_product_id'));
}
public function supportAction()
{
if (!($this->user_id > 0))
{
$this->response->redirect('/');
return false;
}
$id = $this->dispatcher->getParam('id', 'int', null);
$type = $this->dispatcher->getParam('type', 'string', null);
$_types = ['new', 'closed', 'waiting', 'open'];
if ($id > 0)
{
$ticket = SupportTickets::findFirst($id);
if (!$ticket OR $ticket->userid != $this->user_id)
{
return $this->response->redirect('members/support')->send();
}
$is_closed = false;
$is_add_message = false;
if ($this->request->isPost())
{
$question = $this->request->getPost('question', 'striptags', null);
$btn_close = $this->request->getPost('close', null, null);
$btn_post = $this->request->getPost('post', null, null);
if ($btn_close)
{
$ticket->status = SupportTickets::STATUS_CLOSED;
if ($ticket->save() === true)
{
$is_closed = true;
}
} elseif ($btn_post AND $question)
{
$message = new SupportticketFollowups();
$message->ticket_id = $ticket->id;
$message->message = $question;
$message->admin_id = 0;
if ($message->save() === true)
{
$is_add_message = true;
}
}
}
$this->view->ticket = $ticket;
$this->view->is_closed = $is_closed;
$this->view->is_add_message = $is_add_message;
$this->view->pick('index/support/view');
return;
} elseif (in_array($type, $_types))
{
$this->_get_support_type($type);
return;
} else
{
$tickets =
SupportTickets::find(['userid=:userid:', 'bind' => ['userid' => $this->user_id]]);
$this->view->tickets = $tickets;
return;
}
}
}
答案 0 :(得分:0)
控制器源代码? 在分派之前,请尝试调试已加载的名称空间/类。