Class Page Not Found in PHP Application - php

PHP Application running as docker container throws below error under increased load. Unable to figure out the root cause. Any advice would help?
PHP Fatal error: Uncaught Error: Class 'Page' not found in /var/www/html/vendor/silverstripe/errorpage/src/ErrorPage.php
This is the code of ErrorPage.php:
<?php
namespace SilverStripe\ErrorPage;
use Page;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Storage\GeneratedAssetHandler;
use SilverStripe\CMS\Controllers\ModelAsController;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Director;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Control\HTTPResponse_Exception;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Debug;
class ErrorPage extends Page
{
.....
}

The Page class is imported with use Page;.
Is there a file named Page.php in the same folder as SilverStripe/ErrorPage.php?
If not then that's the problem and use Page; is not correct and should be changed to the correct path or the file should be created with correct code.

Related

Using PHP Class in view works, but not in controller

I'm new to PHP and am trying to use the SNMP class in a controller. I can use it just fine in the view index.phtml, but when I move it to the controller I'm getting the following error:
Fatal error: Class 'Project\Controller\SNMP' not found in /Project/module/Project/src/Project/Controller/ProjectController.php on line 113
It seems like it's looking for the class within the controller, but I'm not sure why. Any ideas?
All I had to do was add use SNMP to the top of the controller. Turns out it worked in the view because the view is not namespaced, while the controller is.

Converting php code to Symfony class

i am using a simple php code with Activexpert to send sms here the intersting part
<?php
if(isset($_POST["submit1"]))
{
$_objSmsProtocolGsm = new Com("ActiveXperts.SmsProtocolGsm");
...
}
?>
it working fine but when i tried to insert it into my controller in symfony
i get an error
Attempted to load class "Com" from namespace
"PFE\SiivtBundle\Controller" in C:\Program Files
(x86)\EasyPHP-DevServer-14.1VC11\data\localweb\Symfony2.5\src\PFE\SiivtBundle\Controller\SiivtController.php
line 835. Do you need to "use" it from another namespace?
while my php code is simple and doesnt include or require any other files
Error message is self-explanatory.
Com class doesn't exist in PFE\SiivtBundle\Controller namespace (which is current namespace in your controller class).
Try:
new \Com("ActiveXperts.SmsProtocolGsm");
The backslash before classname means that we're looking for a class in global namespace

Upload files using Zend Error

I am trying to upload files following Zend's tutorial, but keep getting this error:
[10-Apr-2015 05:14:41 Europe/Berlin] PHP Fatal error: Class 'Album\Controller\UploadForm' not found in /Applications/MAMP/htdocs/zf2-tutorial/module/Album/src/Album/Controller/AlbumController.php on line 120
Look like you forgot to use Your UploadForm class on top of controller class. So in that case when you call directly call Form class from controller it searched into current namespace which is Album\Controller so error coming.
Change it to (Assuming your form class at Album/Form/).
namespace Album\Controller;
use Album\Form\UploadForm;

getting error when adding a class in codeigniter

I am using a Facedtector class for my work. I added the class in my Codeigniter libraries folder and just called from my controller class. In my controller I also loaded the class but run time it is showing following error:
An Error Was Encountered
Non-existent class: FaceDetector
Please anyone can help me about this.
Thanks
Add your class file inside you library folder of your main application folder.
And then you can use the auto load function of codeigniter
application/config/autoload.php
at the above location and then you can access the class directly or other way of using this use
$this->load->library('Your_Class_Name', 'Path\to\your\class');
This way you can access your class in codeigniter
You can follow below link for autoload of a class library.
https://ellislab.com/codeigniter/user-guide/general/autoloader.html

Trouble using PHPThumb class under namespace

I am trying to use PHPThumb class. Something strange is going on. I have included three files in my script. I've made sure that these files are correctly included.
<?php
include('PHPThumb-master/src/PHPThumb/PHPThumb.php');
include('PHPThumb-master/src/PHPThumb/GD.php');
include('PHPThumb-master/src/PHPThumb/PluginInterface.php');
Each file has a class define under a namespace PHPThumb; Like:
<?php
namespace PHPThumb;
class GD extends PHPThumb { ...
and so on other files too..
But when I try to make an object $gd = new GD(), it says:
Fatal error: Class 'GD' not found ...
What am I doing wrong?
I learned about namespace in PHP here: http://www.php.net/manual/en/language.namespaces.basics.php. So this solved my problem.

Categories