Udemy Flashcards

1
Q

How to install Symfony?

A

composer create-project symfony/website-skeleton my-project

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to run Symfony?

A

php -S 127.0.0.1:8000 -t public

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to install template?

A

composer require twig

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to install Database?

A

composer require doctrine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to easy for create controller?

A

composer require maker

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to create controller with command?

A

bin/console make:controller DefaultController

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to insert data to database?

A

bin/console make:migration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to create table in database after insert data?

A

bin/console doctrine:migrations:migrate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Syntax Before Insert Data To Database

A
$entityManger = $this->getDoctrine()->getManager();
        $user = new User;
        $user->setName('Seng Ponleu');
        $user1 = new User;
        $user1->setName('Choem Rorn');
        $user2 = new User;
        $user2->setName('Ren Rady');
        $user3 = new User;
        $user3->setName('Horm Sopheap');
        $entityManger->persist($user);
        $entityManger->persist($user1);
        $entityManger->persist($user2);
        $entityManger->persist($user3);
        exit($entityManger->flush());
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to set cookie?

A
$cookie = new Cookie(
           'my_cookie', //Cookie name
        'cookie value', // Cookie value
       time() + (2 * 365 * 24 * 60 * 60) // Expires after 2 years
       );
     $res = new Response();
   $res->headers->setCookie($cookie);

   $res->send();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to remove cookie?

A

$res = new Response();

   $res->headers->clearCookie('my_cookie');

   $res->send();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to set session?

A

$session->set(‘name’,’session value’);

    if ($session->get('name')){
        exit($session->get('name'));
    }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to remove session?

A

$session->set(‘name’,’session value’);

    $session->remove('name');

    if ($session->has('name')){
        exit($session->get('name'));
    }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

GET/POST

A

exit($request->query->get(‘page’,’default’));
exit($request->server->get(‘HTTP_HOST’));

    $request->isXmlHttpRequest(); //is it an Ajax request?
    $request->request->get('page');
    $request->files->get('foo');
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to generate url?

A

{{ path(‘home’) }} <br></br>
{{ url(‘home’) }} <br></br>
{{ asset(‘images/logo.png’) }} <br></br>
{{ absolute_url(asset(‘images/logo.png’)) }}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to using app variable?

A

composer require symfony/security-bundle

{{ app.user }}
{{ app.request.get('param') }}
{{ app.environment }}
{{ dump(app.session) }}
17
Q

How to install htaccess?

A

composer require symfony/apache-pack

18
Q

How to get data from input form?

A

exit($request->request->get(‘title’));

19
Q

How to install asset?

A

composer require symfony/asset