PHP code example of wizards / rest-bundle
1. Go to this page and download the library: Download wizards/rest-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wizards / rest-bundle example snippets
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Wizards\RestBundle\Controller\JsonControllerTrait;
class ArtistController extends AbstractController
{
use JsonControllerTrait;
public function postArtistAction(Request $request, EntityManagerInterface $entityManager)
{
$artist = new Artist();
$form = $this->createForm(ArtistType::class, $artist);
$this->handleJsonForm($form, $request);
if (!$form->isValid()) {
$this->throwRestErrorFromForm($form);
}
$entityManager->persist($artist);
$entityManager->flush();
return $artist;
}
}