Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- composer
- create symfony project
- composer create-project symfony/framework-standard-edition nameOfPROJECT
- 1.enter
- 2.enter;
- 3.database name
- 4.database_username:root
- 5.database_password:root
- 6.enter
- 7.enter
- 8.enter
- 9.enter
- 10.enter
- ------------------------------
- run project
- php bin/console server:run
- ----------------------------
- format code
- crtl+alt+f
- izbacuje nekoristene stvari
- ctrl+alt+o
- crtl+x cut
- -------------------------------
- php bin/console doctrine:scheme:create
- php bin/console doctrine:scheme:drop --force
- -------------------------------
- uvje na pocetku svakog viewa
- {% extends 'base' %} - to je kostur naseg html
- *****
- {% block title %} ako u kosturu imamo ovaj blok ovako ga overajdujemo na novoj strani sa odgovarajucim sadrzajem
- {% endblock %}
- ******
- {% for car in cars %}
- <tr>
- <td> {{car.make}}</td>
- <td> <a href=" url('show_car', {id: car.id } }}"> Show details</a> </td> //show_car je metoda u controleru
- </tr>
- {% endfor %}
- ------------------------------
- Repository
- Default controller
- get cars from database
- $carRepository = $this->getDoctrine()->getRepository('CarBundle:Car');
- $cars = $carRepository->findAll();
- -----------------------
- field in class
- /**
- * @var string
- * $ORM\Column(name=>"description", type="text", nullable=true)
- */
- private $description;
- moguce je u IDE koristiti komandu Getters and Setters
- nakon promjene klase (u Entity) moramo izvsiti update Schema
- php bin/console doctrine:scheme:upadate --force
- za pretragu po id koristimo (metoda u controlleru
- /**
- * $param $id
- * @Route("/car/{id}", name="show_car")
- */
- public function showAction()
- {
- $carRepository = $this->getDoctrine()->getRepository('CarBundle:Car');
- $car = $carRepository->find($id);
- return $this->render('CarBundle:Default:show.html.twig', ['car' => $car] );
- }
- -----------------------------
- extend and update existing entity
- * $ORM\Column(name=>"price", type="float", scale=2) //scale je broj cifara iza decimalnog zareza
- generate getters and setters by console
- php bin/console doctrine:generate:entities CarBundle
- nakon toga da ti updejtovali bazu
- php bin/console doctrine:scheme:upadate --force
- **************
- u View
- <td>{% if car.navigation %}
- <span class="glyphicon glyphicon-ok"></span>
- {% else %}
- <span class="glyphicon glyphicon-remove"></span>
- {% endif %}
- </td>
- -------------------------------------------
- One to many realtion between entities
- php bin/console doctrine:generate:entity --entity="CarBundle:Make" --fields="name:string(255)"
- 1.enter
- 2.enter
- 3.enter
- ***************
- in Car class
- /**
- * @var Model
- *
- * $ORM\ManyToOne(TargetEntity="CarBundle\Entity\Model", inversedBy="cars")
- */
- private $model;
- ***************
- in Make class
- /**
- * @var ArrayCollection
- *
- * $ORM\OneToMany(TargetEntity="CarBundle\Entity\Car", mappedBy="make")
- */
- private $cars;
- *********************
- php bin/console doctrine:generate:entites CarBundle
- php bin/console doctrine:scheme:upadate --force
- ----------------------
- {{ include ('micro-post/post.html.twig', {'post':post} ) }}
- ----------------------
- flash messages
- FlashBagInterface $flashBag
- $this->flashBag->add('notice',"Micro post was deleted');
- {% for message in app.flashes('notice') %}
- <div class="alert-success">
- {{message}}
- </div>
- {% endfor %}
- ---------------
- create user
- php bin/console make:entity
- php bin/console doctrine:migration:diff
- php bin/console doctrine:migration:migrate
- php bin/console doctrine:fixtures:load
- y
- stigao do 36 videa
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement