automatizace jednodušše (6. sraz přátel symfony v praze)

47
6. sraz přátel Symfony - Bude stovka stačit? Praha, 31. 3. 2016, Usertech

Upload: martin-zeman

Post on 15-Jan-2017

173 views

Category:

Presentations & Public Speaking


0 download

TRANSCRIPT

Page 1: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

6. sraz přátel Symfony - Bude stovka stačit?Praha, 31. 3. 2016, Usertech

Page 2: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

Martin Zeman

@zemistr

Page 3: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

Dnešní téma:

Automatizace jednodušše

To není překlep...to je schválně! Přeci jen, je to ukázka automatizace pro kriply. ;-)

Page 4: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

Auto … co?

Page 5: Automatizace jednodušše (6. sraz přátel Symfony v Praze)
Page 6: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

Automatizace označuje použití samočinných řídicích systémů k řízení technologických

zařízení a procesů. Z pohledu industrializace jde o krok následující po mechanizaci.

Zatímco mechanizace poskytuje lidem k práci zařízení, které jim usnadňuje práci,

automatizace snižuje potřebu přítomnosti člověka při vykonávání určité činnosti.

https://cs.wikipedia.org/wiki/Automatizace

Page 7: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

Automatizace označuje použití samočinných řídicích systémů k řízení technologických

zařízení a procesů. Z pohledu industrializace jde o krok následující po mechanizaci.

Zatímco mechanizace poskytuje lidem k práci zařízení, které jim usnadňuje práci,

automatizace snižuje potřebu přítomnosti člověka při vykonávání určité činnosti.

https://cs.wikipedia.org/wiki/Automatizace

Page 8: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

Co můžemeautomatizovat?

Page 9: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

Cokoliv … :)

Page 10: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

● Generování dat (statistiky)● Zpracování dat (newsletter)● Spouštění procesů (viz. ↑ )● … osvětlení● … splachování● … fakt cokoliv :)

Page 11: Automatizace jednodušše (6. sraz přátel Symfony v Praze)
Page 12: Automatizace jednodušše (6. sraz přátel Symfony v Praze)
Page 13: Automatizace jednodušše (6. sraz přátel Symfony v Praze)
Page 14: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

$ bin/consoledoctrine:generate:entity

Page 15: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

The Entity shortcut name: Welcome to the Doctrine2 entity generator

This command helps you generate Doctrine2 entities.

First, you need to give the entity name you want to generate.You must use the shortcut notation like AcmeBlogBundle:Post.

Page 16: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

AppBundle:PostConfiguration format (yml, xml, php, or annotation) [annotation]: Determine the format to use for the mapping information.

New field name (press <return> to stop adding fields): Instead of starting with a blank entity, you can add some fields now.Note that the primary key will be added automatically (named id).

Available types: array, simple_array, json_array, object, boolean, integer, smallint, bigint, string, text, datetime, datetimetz, date, time, decimal, float, binary, blob, guid.

Page 17: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

titleField type [string]: Field length [255]: Is nullable [false]: Unique [false]:

New field name (press <return> to stop adding fields): key Name "key" is a reserved word.

New field name (press <return> to stop adding fields): ukeyField type [string]: Field length [255]: 50Is nullable [false]: trueUnique [false]: true

Page 18: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

Entity generation

> Generating entity class ...\AppBundle\Entity\Post.php: OK!> Generating repository class ...\AppBundle\Repository\PostRepository.php: OK!

Everything is OK! Now get to work :).

Process finished with exit code 0 at 14:41:16.Execution time: 1 032 236 ms.

Page 19: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

/*** @ORM\Table(name="post")* @ORM\Entity(repositoryClass="AppBundle\Repository\PostRepository")*/class Post{ /** * @var int * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id;

/** * @var string * * @ORM\Column(name="title", type="string", length=255) */ private $title;

/** * @var string * * @ORM\Column(name="ukey", type="string", length=50, nullable=true, unique=true) */ private $ukey;

Page 20: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

$ bin/consoledoctrine:generate:entity

Page 21: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

$ bin/consoledoctrine:generate:entity

--entity=AppBundle:Post

Page 22: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

$ bin/consoledoctrine:generate:entity

--entity=AppBundle:Post--no-interaction

Page 23: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

$ bin/consoledoctrine:generate:entity

--entity=AppBundle:Post--fields="title:string(255)"

--no-interaction

Page 24: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

--fields= " ukey:string( length=50 unique=true nullable=true ) title:string(255) "

Page 25: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

$ bin/consoledoctrine:generate:entity

--entity=AppBundle:Post--fields="ukey:string(length=50

unique=true nullable=true)title:string(255)"--no-interaction

Page 26: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

/*** @ORM\Table(name="post")* @ORM\Entity(repositoryClass="AppBundle\Repository\PostRepository")*/class Post{ /** * @var int * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id;

/** * @var string * * @ORM\Column(name="title", type="string", length=255) */ private $title;

/** * @var string * * @ORM\Column(name="ukey", type="string", length=50, nullable=true, unique=true) */ private $ukey;

Page 27: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

$ bin/consoledoctrine:generate:entity

--entity=AppBundle:Post--fields="ukey:string(length=50

unique=true nullable=true)title:string(255)"--no-interaction

Page 28: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

1.

Page 29: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

2.

Page 30: Automatizace jednodušše (6. sraz přátel Symfony v Praze)
Page 31: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

AppBundle:$Prompt$

Page 32: Automatizace jednodušše (6. sraz přátel Symfony v Praze)
Page 33: Automatizace jednodušše (6. sraz přátel Symfony v Praze)
Page 34: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

...\php.exe bin/console doctrine:generate:entity --entity=AppBundle:Post "--fields=ukey:string(length=50 unique=true nullable=true) title:string(255)" --no-interaction Entity generation > Generating entity class ...\AppBundle\Entity\Post.php: OK!> Generating repository class ...\AppBundle\Repository\PostRepository.php: OK!

Everything is OK! Now get to work :).

Process finished with exit code 0

Page 35: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

/** * @var string * * @ORM\Column(name="`key`", ...) */private $key;

Page 36: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

/*** @var string** @ORM\Column(* name="body",* type="text",* nullable=true* )*/private $body;

Page 37: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

$ bin/consoledoctrine:generate:entities

Page 38: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

$ bin/consoledoctrine:generate:entities

AppBundle:Post

Page 39: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

1.

Page 40: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

2.

Page 41: Automatizace jednodušše (6. sraz přátel Symfony v Praze)
Page 42: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

AppBundle:$FileNameWithoutAllExtensions$

Page 43: Automatizace jednodušše (6. sraz přátel Symfony v Praze)
Page 44: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

...\php.exe bin/console doctrine:generate:entities AppBundle:Post

Generating entity "AppBundle\Entity\Post" > backing up Post.php to Post.php~ > generating AppBundle\Entity\Post

Process finished with exit code 0

Page 45: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

/*** Set body** @param string $body* @return Post*/public function setBody($body){ $this->body = $body;

return $this;}

/*** Get body** @return string*/public function getBody(){ return $this->body;}

Page 46: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

Čas na volnou debatu

Page 47: Automatizace jednodušše (6. sraz přátel Symfony v Praze)

Otázky?