Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Who am I A Dutchy in Kiwiland 16 march, 2016 • Wellington • Simon Erkelens ● Simon ● I work for SilverStripe ● @Firesphere ● https://github.com/firesphere ● https://speakerdeck.com/firesphere ● You know it’s me, when you see Hans ○ Except maybe on Twitter This is Hans, my RDD tool. She’s a cow

Slide 3

Slide 3 text

DataObject Annotations 16 march, 2016 • Wellington • Simon Erkelens It may be hard to write, but it doesn’t have to be hard to use Because typing @property is boring

Slide 4

Slide 4 text

What are annotations Class and function annotations and usages 16 march, 2016 • Wellington • Simon Erkelens ● PHP Docblocks ● Usage ● Class information ○ @author/@description/@property/@method/@package ● Function descriptions ○ @param/@return/@throws/@deprecated ● Code Completion ● Pat your IDE. He/she’s very happy you use docblocks

Slide 5

Slide 5 text

Annotations What does it look like /** * @property string Title * @property string Content * @property string URLSegment * @property string FAIcon * @method SpecialPage SpecialPage * @method Image Impression */ This is the class class Special extends DataObject { public static $db = array( 'Title' => 'Varchar(255)', 'Content' => 'HTMLText', 'URLSegment' => 'Varchar(255)', 'FAIcon' => 'Varchar(255)' ); public static $has_one = array( 'SpecialPage' => 'SpecialPage', 'Impression' => 'Image', ); } 16 march, 2016 • Wellington • Simon Erkelens Docblocks in your files

Slide 6

Slide 6 text

Documenting your classes Fun times! Greatest thing about being a developer, right? 16 march, 2016 • Wellington • Simon Erkelens ● Class docblock ● @author ● @description ● @property ● @method ● @package ● @mixin ● @depends ● etc. ● And let’s not forget the description

Slide 7

Slide 7 text

Documenting your functions Fun times! Greatest thing about being a developer, right? 16 march, 2016 • Wellington • Simon Erkelens ● Class docblock ● @param ● @returns ● @throws ● @deprecated ● And again, description ● If it’s hard to write, it should be hard to read ○ right? ● Sorry, can’t help you there

Slide 8

Slide 8 text

Creating docblocks on your class Fun times! Greatest about being a developer, right? 16 march, 2016 • Wellington • Simon Erkelens ● Let’s get started with the fun stuff! ● IDEAnnotator https://github.com/axyr/silverstripe-ideannotator ● StartGeneratedWithDataObjectAnnotator ● @property ● @mixin ● @method ● EndGeneratedWithDataObjectAnnotator

Slide 9

Slide 9 text

DEMO! 16 march, 2016 • Wellington • Simon Erkelens Let’s see what I’m talking about IDEAnnotator

Slide 10

Slide 10 text

DEMO! 16 march, 2016 • Wellington • Simon Erkelens It works!

Slide 11

Slide 11 text

Installation and configuration How to install and use 16 march, 2016 • Wellington • Simon Erkelens ● $ composer require axyr/silverstripe-ideannotator --dev ● ONLY RUN IN DEV MODE!!! ● Enable in _config.php or config.yml ● _config.php if(Director::isDev()) { Config::inst()->update('DataObjectAnnotator', 'enabled', true); Config::inst()->update('DataObjectAnnotator', 'enabled_modules', array('mysite', 'otherfolderinsiteroot') ); }

Slide 12

Slide 12 text

Installation and configuration How to install and use 16 march, 2016 • Wellington • Simon Erkelens ● $ composer require axyr/silverstripe-ideannotator --dev ● ONLY RUN IN DEV MODE!!! ● Enable in _config.php or config.yml ● config.yml --- Only: environment: 'dev' --- DataObjectAnnotator: enabled: true enabled_modules: - mysite - ss3Gallery

Slide 13

Slide 13 text

Only in dev mode Really, don’t do this on live 16 march, 2016 • Wellington • Simon Erkelens ● Literally alters the content of your file ● Despite testing, we can’t promise your file isn’t broken :’( ● There’s no use for updating annotations on live ● It’s for your IDE, not your visitor ● It’s okay to commit them to your repository though ● ?skipannotation=true

Slide 14

Slide 14 text

But why? Because it’s possible? 16 march, 2016 • Wellington • Simon Erkelens ● Save time ● Instantly all options and methods available in your IDE ● Let the annotator do the thinking ● No more accidental @property where you mean @method ● Even the ID properties for has_one relations are there ● Help yourself, help others

Slide 15

Slide 15 text

Wished features It’s only just a tiny module, you can help make it big 16 march, 2016 • Wellington • Simon Erkelens ● It’s far from done ● Multiple classes in one file ● Page_Controller @mixins Page|datarecord ● allowed_actions? https://github.com/axyr/silverstripe-ideannotator I was told to add a kitten to my presentation

Slide 16

Slide 16 text

Thank you! @Firesphere [email protected] https://speakerdeck.com/firesphere 16 march, 2016 • Wellington • Simon Erkelens