Install Dependencies:
composer require ais/prodibundle:dev-master
Ensure your composer.json includes all required dev dependencies (e.g., sensio/generator-bundle, phpunit/phpunit).
Register Bundles in app/AppKernel.php:
new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
new FOS\RestBundle\FOSRestBundle(),
new JMSSerializerBundle\JMSSerializerBundle(),
new Ais\ProdiBundle\AisProdiBundle(),
Configure Routing in app/config/routing.yml:
ais_prodis:
type: rest
prefix: /api
resource: "@AisProdiBundle/Resources/config/routes.yml"
NelmioApiDocBundle:
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
prefix: /api/doc
Clear Cache:
php app/console cache:clear
Access API Docs:
Visit http://localhost/app_dev.php/api/doc to explore endpoints.
The bundle likely abstracts Prodi-related logic (e.g., product management). Start by inspecting:
@AisProdiBundle/Controller/ for RESTful endpoints.@AisProdiBundle/Entity/ for Prodi models (e.g., Product, Order).JMSSerializerBundle to format responses (e.g., @Serializer\Annotation\Groups).Example workflow:
Product) with annotations:
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
#[ORM\Entity]
#[Serializer\ExclusionPolicy("ALL")]
class Product {
#[Serializer\Expose]
#[ORM\Id]
private $id;
// ...
}
curl -X POST http://localhost/api/products -d '{"name":"Test"}'
RESTful API Development:
FOSRestBundle for request/response handling. Use @Rest\View in controllers:
use FOS\RestBundle\Controller\Annotations as Rest;
class ProductController extends Controller {
#[Rest\View]
public function getAction() {
return $this->getDoctrine()->getRepository('AisProdiBundle:Product')->findAll();
}
}
Symfony\Validator or FOSRestBundle's @Rest\QueryParam.Doctrine Integration:
#[ORM\PrePersist]
public function setCreatedAt() {
$this->createdAt = new \DateTime();
}
$products = $this->getDoctrine()
->getRepository('AisProdiBundle:Product')
->findBy(['category' => 'Electronics']);
API Documentation:
NelmioApiDocBundle:
/**
* @ApiDoc(
* resource=true,
* description="Get all products",
* output={"class"="Ais\ProdiBundle\Entity\Product"}
* )
*/
public function getAction() { ... }
php app/console nelmio:apidoc:generate
Testing:
LiipFunctionalTestBundle for API tests:
public function testGetProducts() {
$client = static::createClient();
$client->request('GET', '/api/products');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
}
Custom Controllers:
AisProdiBundle's base controllers (if provided) to add business logic:
class CustomProductController extends AisProdiBundle\Controller\ProductController {
public function customAction() { ... }
}
Event Subscribers:
postPersist) for side effects:
use Doctrine\Common\EventSubscriber;
class ProductSubscriber implements EventSubscriber {
public function getSubscribedEvents() {
return ['postPersist'];
}
public function postPersist(LifecycleEventArgs $args) { ... }
}
Asset Management:
AsseticBundle for SCSS/JS processing (e.g., for frontend assets tied to Prodi entities).Email Notifications:
SwiftmailerBundle for order confirmations:
$message = $this->get('swiftmailer.mailer')->createMessage()
->setTo('[email protected]')
->setBody('Order confirmed!');
$this->get('swiftmailer.mailer')->send($message);
Symfony 2.7 Legacy:
find() instead of findOrFail() (Laravel-specific).Bundle Dependencies:
NelmioApiDocBundle, FOSRestBundle) are registered. Missing dependencies cause silent failures.php app/console debug:container --parameters
Routing Conflicts:
/api/products vs. /products).Serialization Issues:
JMSSerializer. Use @Serializer\MaxDepth or @Serializer\VirtualProperty:
#[Serializer\VirtualProperty]
public function getFormattedName() {
return $this->name . ' (ID: ' . $this->id . ')';
}
Dev-Master Instability:
dev-master branch may lack tests. Test thoroughly in a staging environment.Enable Profiler:
// app/config/config_dev.yml
web_profiler: { toolbar: true, intercept_redirects: false }
Access /_profiler/ for SQL, logs, and request details.
Log Entries:
MonologBundle to trace Prodi operations:
$this->get('logger')->info('Product created', ['product_id' => $product->getId()]);
Doctrine Debugging:
php app/console doctrine:query:sql --em=default
API Doc Regeneration:
php app/console cache:clear && php app/console nelmio:apidoc:generate
Custom Entities:
Product) by overriding methods or adding fields:
#[ORM\Entity]
class ExtendedProduct extends \Ais\ProdiBundle\Entity\Product {
#[ORM\Column]
private $customField;
}
Event Dispatchers:
ProductUpdatedEvent) and dispatch them:
$event = new ProductUpdatedEvent($product);
$this->get('event_dispatcher')->dispatch('product.updated', $event);
Twig Extensions:
class ProdiExtension extends \Twig_Extension {
public function getFilters() {
return ['prodi_format' => new \Twig_SimpleFilter('prodi_format', [$this, 'formatProdiData'])];
}
}
Command-Line Tools:
class ImportProductsCommand extends ContainerAwareCommand {
protected function execute(InputInterface $input, OutputInterface $output) {
// Import logic here
}
}
Register in app/config/commands.yml:
commands:
ais:import_products: ~
How can I help you explore Laravel packages today?