SlideShare uma empresa Scribd logo
1 de 38
Baixar para ler offline
Et si on en finissait avec
CRUD ?
0. Disclaimer
J’ai utilisé, j’utilise et j’utiliserais
encore CRUD
Disclaimer
Un bon dev peut faire de bonne
chose même avec une mauvaise
archi
Disclaimer
1. Définition
Create : créer
Read : lire
Update : mettre à jour
Delete : supprimer
En architecture logiciel
1. Avantages
Avantages
Exemple avec Symfony
/**
* @ORMEntity()
*/
class Tag implements JsonSerializable
{
/**
* @ORMId
* @ORMGeneratedValue
* @ORMColumn(type="integer")
*/
private int $id;
/**
* @ORMColumn(type="string", unique=true)
*/
private string $name;
Exemple avec Symfony
/**
* @ORMEntity()
*/
class Post
{
/**
* @ORMId
* @ORMGeneratedValue
* @ORMColumn(type="integer")
*/
private $id;
/**
* @ORMColumn(type="string")
* @AssertNotBlank
*/
private $title;
/**
* @ORMColumn(type="string")
*/
private $slug;
/**
* @ORMColumn(type="string")
* @AssertNotBlank(message="post.blank_summary")
* @AssertLength(max=255)
*/
private $summary ;
/**
* @ORMColumn(type="text")
* @AssertNotBlank(message="post.blank_content")
* @AssertLength(min=10, minMessage="post.too_short_content")
*/
private $content ;
/**
* @ORMColumn(type="datetime")
*/
private $publishedAt ;
/**
* @ORMManyToOne(targetEntity="AppEntityUser")
* @ORMJoinColumn(nullable=false)
*/
private $author;
/**
* @ORMOneToMany(
* targetEntity="Comment",
* mappedBy="post",
* orphanRemoval=true,
* cascade={"persist"}
* )
* @ORMOrderBy({"publishedAt": "DESC"})
*/
private $comments ;
/**
* @ORMManyToMany(targetEntity="AppEntityTag", cascade={"persist
* @ORMJoinTable(name="symfony_demo_post_tag")
* @ORMOrderBy({"name": "ASC"})
* @AssertCount(max="4", maxMessage="post.too_many_tags")
*/
private $tags;
class PostType extends AbstractType
{
public function buildForm (FormBuilderInterface $builder , array $options ): void
{
$builder
->add('title', null, [
'attr' => ['autofocus' => true],
'label' => 'label.title' ,
])
-> add('summary' , TextareaType ::class, [
'help' => 'help.post_summary' ,
'label' => 'label.summary' ,
])
-> add('content' , null, [
'attr' => ['rows' => 20],
'help' => 'help.post_content' ,
'label' => 'label.content' ,
])
-> add('publishedAt' , DateTimePickerType ::class, [
'label' => 'label.published_at' ,
'help' => 'help.post_publication' ,
])
-> add('tags', TagsInputType ::class, [
'label' => 'label.tags' ,
'required' => false,
])
->addEventListener (FormEvents ::SUBMIT, function (FormEvent $event) {
$post = $event->getData();
if (null !== $postTitle = $post->getTitle ()) {
$post->setSlug($this->slugger->slug($postTitle )->lower());
}
})
;
}
/**
* @Route("/admin/post")
* @IsGranted("ROLE_ADMIN")
*/
class BlogController extends AbstractController
{
/**
* @Route("/new", methods="GET|POST", name="admin_post_new")
*/
public function new(Request $request ): Response
{
$post = new Post();
$post->setAuthor ($this->getUser());
$form = $this->createForm (PostType ::class, $post)
-> add('saveAndCreateNew' , SubmitType ::class);
$form->handleRequest ($request );
if ($form->isSubmitted () && $form->isValid()) {
$em = $this->getDoctrine ()->getManager ();
$em->persist($post);
$em->flush();
$this->addFlash ('success' , 'post.created_successfully' );
if ($form->get('saveAndCreateNew' )->isClicked ()) {
return $this->redirectToRoute ('admin_post_new' );
}
return $this->redirectToRoute ('admin_post_index' );
}
return $this->render('admin/blog/new.html.twig' , [
'post' => $post,
'form' => $form->createView (),
]);
}
/**
* @Route("/{id<d+>}", methods="GET", name="admin_post_show")
*/
public function show(Post $post): Response
{
$this->denyAccessUnlessGranted (PostVoter ::SHOW, $post, 'Posts can only be shown to their authors.' );
return $this->render('admin/blog/show.html.twig' , [
'post' => $post,
]);
}
/**
* @Route("/{id<d+>}/edit", methods="GET|POST", name="admin_post_edit")
* @IsGranted("edit", subject="post", message="Posts can only be edited by their authors.")
*/
public function edit(Request $request , Post $post): Response
{
$form = $this->createForm (PostType ::class, $post);
$form->handleRequest ($request );
if ($form->isSubmitted () && $form->isValid()) {
$this->getDoctrine ()->getManager ()->flush();
$this->addFlash ('success' , 'post.updated_successfully' );
return $this->redirectToRoute ('admin_post_edit' , ['id' => $post->getId()]);
}
return $this->render('admin/blog/edit.html.twig' , [
'post' => $post,
'form' => $form->createView (),
]);
}
/**
* @Route("/{id}/delete", methods="POST", name="admin_post_delete")
* @IsGranted("delete", subject="post")
*/
public function delete(Request $request , Post $post): Response
{
if (!$this->isCsrfTokenValid ('delete' , $request ->request->get('token'))) {
return $this->redirectToRoute ('admin_post_index' );
}
$post->getTags()->clear();
$em = $this->getDoctrine ()->getManager ();
$em->remove($post);
$em->flush();
$this->addFlash ('success' , 'post.deleted_successfully' );
return $this->redirectToRoute ('admin_post_index' );
}
}
Sur le papier c’est GENIAL...
Sur le PAPIER c’est génial...
En vrais
2. Inconvénients
Inconvénients
Inconvénients
Inconvénients
Inconvénients
Historique
●
●
●
●
●
Historique
●
●
●
●
●
Historique
●
●
●
○
○
●
●
3. Solutions
Tuons les BDD et CRUD
Tuons les BDD et CRUD
Tuons les BDD et CRUD
Tuons les BDD et CRUD
Workflow
Workflow
Event Sourcing
Pas garantie à 100%
Event Sourcing
Event Sourcing
●
●
●
●
Event Sourcing
●
●
●

Mais conteúdo relacionado

Mais procurados

Object Calisthenics Applied to PHP
Object Calisthenics Applied to PHPObject Calisthenics Applied to PHP
Object Calisthenics Applied to PHPGuilherme Blanco
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix itRafael Dohms
 
Building Your First Widget
Building Your First WidgetBuilding Your First Widget
Building Your First WidgetChris Wilcoxson
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix itRafael Dohms
 
Working With JQuery Part1
Working With JQuery Part1Working With JQuery Part1
Working With JQuery Part1saydin_soft
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsGuilherme Blanco
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologyDaniel Knell
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHPTaras Kalapun
 
Gérer vos objets
Gérer vos objetsGérer vos objets
Gérer vos objetsThomas Gasc
 
Doctrine fixtures
Doctrine fixturesDoctrine fixtures
Doctrine fixturesBill Chang
 
PHP object calisthenics
PHP object calisthenicsPHP object calisthenics
PHP object calisthenicsGiorgio Cefaro
 
Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)Arnaud Langlade
 
Crafting beautiful software
Crafting beautiful softwareCrafting beautiful software
Crafting beautiful softwareJorn Oomen
 
The Truth About Lambdas in PHP
The Truth About Lambdas in PHPThe Truth About Lambdas in PHP
The Truth About Lambdas in PHPSharon Levy
 

Mais procurados (20)

Object Calisthenics Applied to PHP
Object Calisthenics Applied to PHPObject Calisthenics Applied to PHP
Object Calisthenics Applied to PHP
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix it
 
Building Your First Widget
Building Your First WidgetBuilding Your First Widget
Building Your First Widget
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix it
 
Abap basics 01
Abap basics 01Abap basics 01
Abap basics 01
 
Working With JQuery Part1
Working With JQuery Part1Working With JQuery Part1
Working With JQuery Part1
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object Calisthenics
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
 
linieaire regressie
linieaire regressielinieaire regressie
linieaire regressie
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHP
 
Gérer vos objets
Gérer vos objetsGérer vos objets
Gérer vos objets
 
Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01
 
Doctrine fixtures
Doctrine fixturesDoctrine fixtures
Doctrine fixtures
 
PHP object calisthenics
PHP object calisthenicsPHP object calisthenics
PHP object calisthenics
 
Dollar symbol
Dollar symbolDollar symbol
Dollar symbol
 
Smelling your code
Smelling your codeSmelling your code
Smelling your code
 
Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)
 
Crafting beautiful software
Crafting beautiful softwareCrafting beautiful software
Crafting beautiful software
 
Dades i operadors
Dades i operadorsDades i operadors
Dades i operadors
 
The Truth About Lambdas in PHP
The Truth About Lambdas in PHPThe Truth About Lambdas in PHP
The Truth About Lambdas in PHP
 

Semelhante a Et si on en finissait avec CRUD ?

How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony AppsKris Wallsmith
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Leonardo Proietti
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Tidy Up Your Code
Tidy Up Your CodeTidy Up Your Code
Tidy Up Your CodeAbbas Ali
 
Why is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosWhy is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosDivante
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsSam Hennessy
 
Symfony CoP: Form component
Symfony CoP: Form componentSymfony CoP: Form component
Symfony CoP: Form componentSamuel ROZE
 
Refactoring using Codeception
Refactoring using CodeceptionRefactoring using Codeception
Refactoring using CodeceptionJeroen van Dijk
 
Apostrophe
ApostropheApostrophe
Apostrophetompunk
 
Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0Yevhen Kotelnytskyi
 
Coding for Scale and Sanity
Coding for Scale and SanityCoding for Scale and Sanity
Coding for Scale and SanityJimKellerES
 
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXМихаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXDrupalSib
 
How kris-writes-symfony-apps-london
How kris-writes-symfony-apps-londonHow kris-writes-symfony-apps-london
How kris-writes-symfony-apps-londonKris Wallsmith
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksNate Abele
 
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2eugenio pombi
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hackingJeroen van Dijk
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutesBarang CK
 

Semelhante a Et si on en finissait avec CRUD ? (20)

How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Tidy Up Your Code
Tidy Up Your CodeTidy Up Your Code
Tidy Up Your Code
 
Why is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosWhy is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenarios
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy Applications
 
Symfony CoP: Form component
Symfony CoP: Form componentSymfony CoP: Form component
Symfony CoP: Form component
 
Refactoring using Codeception
Refactoring using CodeceptionRefactoring using Codeception
Refactoring using Codeception
 
Apostrophe
ApostropheApostrophe
Apostrophe
 
Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0
 
Coding for Scale and Sanity
Coding for Scale and SanityCoding for Scale and Sanity
Coding for Scale and Sanity
 
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXМихаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
 
How kris-writes-symfony-apps-london
How kris-writes-symfony-apps-londonHow kris-writes-symfony-apps-london
How kris-writes-symfony-apps-london
 
Code me a HR
Code me a HRCode me a HR
Code me a HR
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
 
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
 
Lithium Best
Lithium Best Lithium Best
Lithium Best
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutes
 

Mais de Julien Vinber

Swoole Meetup AFUP¨Montpellier 27/01/2021
Swoole   Meetup  AFUP¨Montpellier 27/01/2021Swoole   Meetup  AFUP¨Montpellier 27/01/2021
Swoole Meetup AFUP¨Montpellier 27/01/2021Julien Vinber
 
Php 7.4 2020-01-28 - afup
Php 7.4   2020-01-28 - afupPhp 7.4   2020-01-28 - afup
Php 7.4 2020-01-28 - afupJulien Vinber
 
Meet up symfony 16 juin 2017 - Les PSR
Meet up symfony 16 juin 2017 -  Les PSRMeet up symfony 16 juin 2017 -  Les PSR
Meet up symfony 16 juin 2017 - Les PSRJulien Vinber
 
Meet up symfony 11 octobre 2016 - Les formulaire
Meet up symfony 11 octobre 2016 - Les formulaireMeet up symfony 11 octobre 2016 - Les formulaire
Meet up symfony 11 octobre 2016 - Les formulaireJulien Vinber
 
Meetup symfony 30 janvier 2017 - événement
Meetup symfony 30 janvier 2017 - événementMeetup symfony 30 janvier 2017 - événement
Meetup symfony 30 janvier 2017 - événementJulien Vinber
 

Mais de Julien Vinber (8)

PHP8.2_SF8.2.pdf
PHP8.2_SF8.2.pdfPHP8.2_SF8.2.pdf
PHP8.2_SF8.2.pdf
 
Sulu LE CMS Ultime
Sulu LE CMS UltimeSulu LE CMS Ultime
Sulu LE CMS Ultime
 
Swoole Meetup AFUP¨Montpellier 27/01/2021
Swoole   Meetup  AFUP¨Montpellier 27/01/2021Swoole   Meetup  AFUP¨Montpellier 27/01/2021
Swoole Meetup AFUP¨Montpellier 27/01/2021
 
Php 7.4 2020-01-28 - afup
Php 7.4   2020-01-28 - afupPhp 7.4   2020-01-28 - afup
Php 7.4 2020-01-28 - afup
 
Symfony vs laravel
Symfony vs  laravelSymfony vs  laravel
Symfony vs laravel
 
Meet up symfony 16 juin 2017 - Les PSR
Meet up symfony 16 juin 2017 -  Les PSRMeet up symfony 16 juin 2017 -  Les PSR
Meet up symfony 16 juin 2017 - Les PSR
 
Meet up symfony 11 octobre 2016 - Les formulaire
Meet up symfony 11 octobre 2016 - Les formulaireMeet up symfony 11 octobre 2016 - Les formulaire
Meet up symfony 11 octobre 2016 - Les formulaire
 
Meetup symfony 30 janvier 2017 - événement
Meetup symfony 30 janvier 2017 - événementMeetup symfony 30 janvier 2017 - événement
Meetup symfony 30 janvier 2017 - événement
 

Último

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 

Último (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 

Et si on en finissait avec CRUD ?

  • 1. Et si on en finissait avec CRUD ?
  • 3. J’ai utilisé, j’utilise et j’utiliserais encore CRUD Disclaimer
  • 4. Un bon dev peut faire de bonne chose même avec une mauvaise archi Disclaimer
  • 6. Create : créer Read : lire Update : mettre à jour Delete : supprimer
  • 10. Exemple avec Symfony /** * @ORMEntity() */ class Tag implements JsonSerializable { /** * @ORMId * @ORMGeneratedValue * @ORMColumn(type="integer") */ private int $id; /** * @ORMColumn(type="string", unique=true) */ private string $name;
  • 12. /** * @ORMEntity() */ class Post { /** * @ORMId * @ORMGeneratedValue * @ORMColumn(type="integer") */ private $id; /** * @ORMColumn(type="string") * @AssertNotBlank */ private $title; /** * @ORMColumn(type="string") */ private $slug; /** * @ORMColumn(type="string") * @AssertNotBlank(message="post.blank_summary") * @AssertLength(max=255) */ private $summary ; /** * @ORMColumn(type="text") * @AssertNotBlank(message="post.blank_content") * @AssertLength(min=10, minMessage="post.too_short_content") */ private $content ; /** * @ORMColumn(type="datetime") */ private $publishedAt ; /** * @ORMManyToOne(targetEntity="AppEntityUser") * @ORMJoinColumn(nullable=false) */ private $author; /** * @ORMOneToMany( * targetEntity="Comment", * mappedBy="post", * orphanRemoval=true, * cascade={"persist"} * ) * @ORMOrderBy({"publishedAt": "DESC"}) */ private $comments ; /** * @ORMManyToMany(targetEntity="AppEntityTag", cascade={"persist * @ORMJoinTable(name="symfony_demo_post_tag") * @ORMOrderBy({"name": "ASC"}) * @AssertCount(max="4", maxMessage="post.too_many_tags") */ private $tags;
  • 13. class PostType extends AbstractType { public function buildForm (FormBuilderInterface $builder , array $options ): void { $builder ->add('title', null, [ 'attr' => ['autofocus' => true], 'label' => 'label.title' , ]) -> add('summary' , TextareaType ::class, [ 'help' => 'help.post_summary' , 'label' => 'label.summary' , ]) -> add('content' , null, [ 'attr' => ['rows' => 20], 'help' => 'help.post_content' , 'label' => 'label.content' , ]) -> add('publishedAt' , DateTimePickerType ::class, [ 'label' => 'label.published_at' , 'help' => 'help.post_publication' , ]) -> add('tags', TagsInputType ::class, [ 'label' => 'label.tags' , 'required' => false, ]) ->addEventListener (FormEvents ::SUBMIT, function (FormEvent $event) { $post = $event->getData(); if (null !== $postTitle = $post->getTitle ()) { $post->setSlug($this->slugger->slug($postTitle )->lower()); } }) ; }
  • 14. /** * @Route("/admin/post") * @IsGranted("ROLE_ADMIN") */ class BlogController extends AbstractController { /** * @Route("/new", methods="GET|POST", name="admin_post_new") */ public function new(Request $request ): Response { $post = new Post(); $post->setAuthor ($this->getUser()); $form = $this->createForm (PostType ::class, $post) -> add('saveAndCreateNew' , SubmitType ::class); $form->handleRequest ($request ); if ($form->isSubmitted () && $form->isValid()) { $em = $this->getDoctrine ()->getManager (); $em->persist($post); $em->flush(); $this->addFlash ('success' , 'post.created_successfully' ); if ($form->get('saveAndCreateNew' )->isClicked ()) { return $this->redirectToRoute ('admin_post_new' ); } return $this->redirectToRoute ('admin_post_index' ); } return $this->render('admin/blog/new.html.twig' , [ 'post' => $post, 'form' => $form->createView (), ]); }
  • 15. /** * @Route("/{id<d+>}", methods="GET", name="admin_post_show") */ public function show(Post $post): Response { $this->denyAccessUnlessGranted (PostVoter ::SHOW, $post, 'Posts can only be shown to their authors.' ); return $this->render('admin/blog/show.html.twig' , [ 'post' => $post, ]); } /** * @Route("/{id<d+>}/edit", methods="GET|POST", name="admin_post_edit") * @IsGranted("edit", subject="post", message="Posts can only be edited by their authors.") */ public function edit(Request $request , Post $post): Response { $form = $this->createForm (PostType ::class, $post); $form->handleRequest ($request ); if ($form->isSubmitted () && $form->isValid()) { $this->getDoctrine ()->getManager ()->flush(); $this->addFlash ('success' , 'post.updated_successfully' ); return $this->redirectToRoute ('admin_post_edit' , ['id' => $post->getId()]); } return $this->render('admin/blog/edit.html.twig' , [ 'post' => $post, 'form' => $form->createView (), ]); }
  • 16. /** * @Route("/{id}/delete", methods="POST", name="admin_post_delete") * @IsGranted("delete", subject="post") */ public function delete(Request $request , Post $post): Response { if (!$this->isCsrfTokenValid ('delete' , $request ->request->get('token'))) { return $this->redirectToRoute ('admin_post_index' ); } $post->getTags()->clear(); $em = $this->getDoctrine ()->getManager (); $em->remove($post); $em->flush(); $this->addFlash ('success' , 'post.deleted_successfully' ); return $this->redirectToRoute ('admin_post_index' ); } }
  • 17. Sur le papier c’est GENIAL...
  • 18. Sur le PAPIER c’est génial...
  • 29. Tuons les BDD et CRUD
  • 30. Tuons les BDD et CRUD
  • 31. Tuons les BDD et CRUD
  • 32. Tuons les BDD et CRUD