I wrote default controller and a task class in symfony. My problem is it throws errors that are related to autoloaders composer.
The autoloader expected class "AppBundle\Entity\Task" to be defined in file "C:\wamp64\www\Form1_Symfony\vendor\composer/../../src/AppBundle\Entity\Task.php". The file was found but the class was not in it, the class name or namespace probably has a typo
how can i fix it?
defaultController.php that use task class and have route and finally create a form and returns it
use AppBundle\Entity\Task;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
class DefaultController extends Controller
{
/**
* @Route("/lk")
*/
public function newAction(Request $request)
{
// create a task and give it some dummy data for this example
$task = new Task();
$task->setTask('Write a blog post');
$task->setDueDate(new \DateTime('tomorrow'));
$form = $this->createFormBuilder($task)
->add('task', TextType::class)
->add('dueDate', DateType::class)
->add('save', SubmitType::class, array('label' => 'Create Post'))
->getForm();
return $this->render('default/new.html.twig', array(
'form' => $form->createView(),
));
}
}
Task.php that return task and time for use in create from later.
<?php
namespace AppBundle\Entity\Task;
class Task
{
protected $task;
protected $date;
public function getTask(){
return $this->task;
}
public function getDate(){
return $this->date;
}
}