I'm using symfony 2.3 framework and the autoloader claims to have found the file but no class:
RuntimeException: The autoloader expected class "Sensio\Bundle\
FrameworkExtraBundle\Request\ParamConverter\DateTimeParamConverter"
to be defined in file "/home/na/auth/vendor/sensio/framework-extra-bundle/
Sensio/Bundle/FrameworkExtraBundle/Request/ParamConverter/
DateTimeParamConverter.php". The file was found but the class was not in it,
the class name or namespace probably has a typo.
The file this is refering to is shown bellow:
<?php
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use DateTime;
/**
* Convert DateTime instances from request attribute variable.
*
* @author Benjamin Eberlei <[email protected]>
*/
class DateTimeParamConverter implements ParamConverterInterface
{
/**
* @{inheritdoc}
*
* @throws NotFoundHttpException When invalid date given
*/
public function apply(Request $request, ConfigurationInterface $configuration)
{
$param = $configuration->getName();
if (!$request->attributes->has($param)) {
return false;
}
$options = $configuration->getOptions();
$value = $request->attributes->get($param);
$date = isset($options['format'])
? DateTime::createFromFormat($options['format'], $value)
: new DateTime($value);
if (!$date) {
throw new NotFoundHttpException('Invalid date given.');
}
$request->attributes->set($param, $date);
return true;
}
/**
* @{inheritdoc}
*/
public function supports(ConfigurationInterface $configuration)
{
if (null === $configuration->getClass()) {
return false;
}
return "DateTime" === $configuration->getClass();
}
}
Anyway, some detail that might help was that I recently installed Doctrine and ran the commands ...
2028 php app/console doctrine:schema:create
2029 php app/console doctrine:generate:entities Auth
After those commands, symfony stopped working. I don't know if this is some weird bug or something. If you need more information, I can post. Thanks for any help.
Missing (or short) PHP opening tag can cause that error too. Yes it sounds funny, but if you just follow Symfony example and copy/paste whole class you may not notice that (as I didn't).
This is a little old now, but in case anyone else gets here by search: This is undoubtedly a cache issue. Manually delete the contents of app/cache/dev and app/cache/prod, and everything should resolve.
If anyone else has this issue and it doesn't go away by clearing the cache, then I recommend removing the entire folder with your composer dependencies and re-executing composer install
.
It worked for me :) .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With