Upload
pehapkari
View
142
Download
2
Embed Size (px)
Citation preview
6. sraz přátel Symfony - Bude stovka stačit?Praha, 31. 3. 2016, Usertech
Martin Zeman
@zemistr
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. ;-)
Auto … co?
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
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
Co můžemeautomatizovat?
Cokoliv … :)
● Generování dat (statistiky)● Zpracování dat (newsletter)● Spouštění procesů (viz. ↑ )● … osvětlení● … splachování● … fakt cokoliv :)
$ bin/consoledoctrine:generate:entity
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.
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.
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
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.
/*** @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;
$ bin/consoledoctrine:generate:entity
$ bin/consoledoctrine:generate:entity
--entity=AppBundle:Post
$ bin/consoledoctrine:generate:entity
--entity=AppBundle:Post--no-interaction
$ bin/consoledoctrine:generate:entity
--entity=AppBundle:Post--fields="title:string(255)"
--no-interaction
--fields= " ukey:string( length=50 unique=true nullable=true ) title:string(255) "
$ bin/consoledoctrine:generate:entity
--entity=AppBundle:Post--fields="ukey:string(length=50
unique=true nullable=true)title:string(255)"--no-interaction
/*** @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;
$ bin/consoledoctrine:generate:entity
--entity=AppBundle:Post--fields="ukey:string(length=50
unique=true nullable=true)title:string(255)"--no-interaction
1.
2.
AppBundle:$Prompt$
...\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
/** * @var string * * @ORM\Column(name="`key`", ...) */private $key;
/*** @var string** @ORM\Column(* name="body",* type="text",* nullable=true* )*/private $body;
$ bin/consoledoctrine:generate:entities
$ bin/consoledoctrine:generate:entities
AppBundle:Post
1.
2.
AppBundle:$FileNameWithoutAllExtensions$
...\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
/*** 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;}
Čas na volnou debatu
Otázky?