Symfony2 - Class XXX not found - php

I have deployed a Symfony Application to a one.com server. I wrote a Mail service that sends my emails via SwiftMailer.
Now, since one.com has no phar-extensions allowed, composer cannot be updated via ssh. So I generated the classmap locally with
composer update -o
Whenever I try to get the Mail service, the application throws an error:
Fatal error: Class
'Stocksolutions\ShopBundle\DependencyInjection\Mail' not found in
/customers/4/b/b/stocksolutions.be/httpd.www/releases/20150204201140/app/cache/dev/appDevDebugProjectContainer.php
on line 3602
I have searched the composer classmap and the class that isn't found is inside it:
'StockSolutions\\ShopBundle\\DependencyInjection\\Mail' => $baseDir . '/src/StockSolutions/ShopBundle/DependencyInjection/Mail.php'
Furthermore, I can get other services in the container, f.e. those from the FOSUserBundle, but getting my custom services throws an error. Also, I don't get these errors when testing locally..
Any ideas?

It's case-sensitive problem.
Your error:
Fatal error: Class
'Stocksolutions\ShopBundle\DependencyInjection\Mail' not found
Small letter s in Stocksolutions namespace for PSR forces to search for the file /src/Stock**s**olutions/ShopBundle/DependencyInjection/Mail.php, but exist /src/Stock**S**olutions/ShopBundle/DependencyInjection/Mail.php.
On local system likely Windows, where the path/filenames case-insensitive, error does not occur.
P.S. Most likely a typo in class namespace is in the bundle service description (services.yml/services.xml).

Related

PHP7 Type error with interface

In my symfony project I got an error with a vendor.
Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to eZ\Publish\Core\MVC\Legacy\Kernel\Loader::setCLIHandler() must implement interface ezpKernelHandler, instance of eZ\Publish\Core\MVC\Legacy\Kernel\CLIHandler given, called in /Users/steve/Projects/Web/BuildSuccess/www/vendor/ezsystems/legacy-bridge/mvc/Kernel/Loader.php on line 237 in /Users/steve/Projects/Web/BuildSuccess/www/vendor/ezsystems/legacy-bridge/mvc/Kernel/Loader.php:255
But this error is strange because I checked and eZ\Publish\Core\MVC\Legacy\Kernel\CLIHandler implements the interface ezpKernelHandler !
namespace eZ\Publish\Core\MVC\Legacy\Kernel;
use ezpKernelHandler;
class CLIHandler implements ezpKernelHandler
{
...
}
I tried to debug, with get_class method and I get
"eZ\Publish\Core\MVC\Legacy\Kernel\CLIHandler"
I also used class_implements method and I get
array(0) {
}
Any idea what append ?
Thanks
I see that it is not your code, but rather eZ Publish itself. Because of this it is unlikely that you will be able to update sources, but there is still some things that you can do:
Check your Composer autoloader configuration to see that ezpKernelHandler class is properly resolved. You may need to register custom autoloader for it.
You're most likely receiving this error because you're using Symfony 3.3+ and its recently added services auto-configuration features. You can avoid this error to be thrown by disabling service auto-configuration for affected service, take a look at example here
Since this error is fatal but catchable - if nothing else will help you can create your own service factory for this particular service and catch error inside it.
Fixed : https://github.com/ezsystems/LegacyBridge/issues/132
It is easilly fixed by creating app/autoload.php file which requires both vendor/autoload.php and ezpublish_legacy/autoload.php and changing bin/console to require that file instead of vendor/autoload.php

Laravel Illuminate/Support/Facade/DB not found

I recently cloned my project from github to my local machine for development. I am using the Laravel framework and have been having issues getting my web service working because it cannot find Illuminate\Support\Facades\DB
My code looks like this
use Illuminate\Support\Facades\DB;
...(filler code)...
$results = DB::select(DB::raw('....'))
I end up getting this as an error:
Uncaught Error: Class 'Illuminate\Support\Facades\DB' not found in /Applications/XAMPP/xamppfiles/htdocs/plotly_dawgs/service_data.php:50
If anyone knows why this might be please let me know.
I've tried reupdating composer dependencies and checked alias => [] in app.php

Symfony project unable to load in localhost

I am new in symfony framework. Getting the below error when download the full project in localhost but it works in server.
Fatal error: Class 'Symfony\Bridge\Doctrine\ManagerRegistry' not found
in D:\wamp\www\DOFE\edin\vendor\doctrine\doctrine-bundle\Registry.php
on line 28
Thanks in advance.
You probably want to execute composer dump-autoload to force composer to regenerate the autoload namespaces for your app.
Regarding your comment, if you are getting this message it means you are in prod and you should switch to the dev environment to have details about the error (access to the symfony profiler).
Just add app_dev.php after the host in the url.

Mailgun SDK unable to find required classes (php)

I'm trying to use the Mailgun API SDK to send emails from my test server. I downloaded the SDK itself as I am not currently using Composer.
However, when I try to instantiate a Mailgun object, I get this error:
Fatal error: Class 'Mailgun\Connection\RestClient' not found in /var/www/mysite.xyz/www/inc/libs/Mailgun/Mailgun.php on line 38
Which I fixed by adding require "Connection/RestClient.php"; to the Mailgun.php file. However, this in turn caused its own error.
Fatal error: Class 'GuzzleHttp\Client' not found in /var/www/mysite.xyz/www/inc/libs/Mailgun/Connection/RestClient.php on line 41
This is included in my includes.php, so for all pages.
#Mailgun php functions
require_once "libs/Mailgun/Mailgun.php";
use Mailgun\Mailgun;
Then, when I try to use this;
# First, instantiate the SDK with your API credentials and define your domain.
$mg = new Mailgun\Mailgun("key-myactualkey");
$domain = "myactualdomain.xyz";
print "Email to send is ".$welcomeemail; #Never gets reached
It causes those fatal errors and the program grinds to a halt.
Why is this happening and how do I fix it?
I had the same problem and fixed it by using composer which is easier then you might think. Just follow these instructions (locally, on your computer, where PHP should be installed):
https://github.com/mailgun/mailgun-php/blob/master/SharedHostInstall.md
Then upload all files generated to your server in a separate directory.
Then include the following lines to your script:
require 'your/path/to/these/files/vendor/autoload.php';
use Mailgun\Mailgun;
Create a new Mailgun object like this:
$mg = new Mailgun("your-secret-key");

Zend Framework 2 error

After a composer update my application don't run anymore.
The error is:
PHP Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\InvalidArgumentException' with message 'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.' in /path_to_app/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:302
I googled the error and seems that in may 2013 happened something similar that could be solved just commenting two lines in the module.config.php
Naturally, I've tried that but it doesn't seem to work.
Any ideas?
You have a factory service configuration issue in your module.config.php, like the error says one of your configured factory services is not a "class name of an abstract factory or an instance of an AbstractFactoryInterface.".
For debugging purpose, try to temporarily disable your application registered modules one by one to detect in which module this is configured (if you have no idea), until the error disappear.
Then check the services configs.

Categories