PHPBenelux Conference 2013

Anotaciones en aplicaciones PHP

Rafael Dohms  · 
PHP

Presentación

Vídeo

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

okay cool so let's kick off first of all I would just like to introduce myself I'm rough albums apparently I'm a Brazilian lost in MCM I moved there last year I'm currently working for web clusive we do awesome couch running stuff so if you

are in the MCM area come talk to me afterwards we might have an interesting offer for you okay so annotations right let's get into this actually it means despite the whole thing right cool so limitations um so this is kind of like your review when I give

you guys first of all I want to go into a little bit of history you know what I annotations where they come from what users have been out there then I'm going to go into a little bit of why I think you should use them or why I like annotations show you

a lady of the existing examples in PHP and then finally you're going to get into more of our hands-on or with the existing annotation engines so you could take that an implemented in your own project cool so first of all you know what is annotations I

mean you look at annotations all over the place people mention them in different languages but what really is annotations if you look at an english definition of annotations they're basically and notes that you make on something you're reading right

y'all used to read a book or something and you write something inside notes or you highlight message you know you always make kind of small scribbles to explain to yourself what that text is saying right so that's kind of like metadata you're putting

more information on top of that existing information that's already in the book alright and that's basically the same thing that annotations are your writing and a new layer on top of your code so some people will scream run time on top of run time

and all that but that's kind of area you're adding metadata to to your code so cool that you know that basically something that's describing that subject just a little bit more so what does that mean for us in code so in cold adaptation is basically

mayor data that's attached to your code and is read and understood during runtime so static it's just code it's not executed by the parser but that's going to be used by your code afterwards to have an effect so that's the variance for

an answer it's very important aspect of it it is not it does not affect your code as static code it will affect your code during the run time so all your code is actually executing is going to be looking upon itself to say hey well this annotation is here

I should do something right so it's basically just like your notes they don't affect your code directly they will be used by something else to then effect the change or implement the behavior on top of your code so just like the notes you make in a

book they don't actually change the content of a book but they change the way someone who's really it will interpret it cool so a little bit of history if we look at some languages which do have support for annotations two examples are Java and then

c hash which has attributes kind of like annotations not one hundred percent but if you go according to what Martin Fowler says this all just different implementations of annotations so Java this is an example it's up basically using the same as a javadoc

you know the documentation syntax before the methods you can include things so in this case this is an example of hibernate where it's describing how it persists something so this is an ID this is how the table is going to be named and so forth in C hash

they have their own syntax so it's just between square brackets and again before the properties method or classes so it's different abilities specific syntax for annotations it doesn't share the same syntax as their documentation like like Java

doc does java has been doing this since version 1.5 and see hash was actually born with it right so that's just a little background these languages have been doing this for a long time and they found really cool ways to do it for example the the example

I found in C hash which people really like is the at deprecated or in this case a square bracket deprecated which will mark methods as deprecated and then the engine itself will start telling you hate your you're using something deprecated you should try

something else and that there was some discussion in PHP about that recently actually cool and you know what about PHP where do we stand with annotations so the truth is that there is no core support for annotations they're just absolutely nothing in the

core to support annotations that's it that's all I have to tell you know thank you so much for coming thank you okay there is something so let's go back a little bit in history to understand you know the whole struggle of annotations in PHP so

back in around the year 2000 something came about called phpdoc so we started using documentation blocks right you know you know we all know lock box nowadays we should if you don't Michael beat you up but you should know right so they came about in around

2000 with the the birth of PHP documentary and then we start the value pattern which is still a work in progress but we have the standard thing that's already mostly used by everyone ok cool so now we have the basis of what we're using today for annotations

but we're missing one thing where we said this was runtime so you have to be able to look at these annotations at one time code needs to look to itself and read those annotations and that came about in 2005 with fee 35.1 where we finally added this method

to refraction the get bak comments so this allows us to retrieve that doc block that's sitting next to a method or class during the execution of the code so i can actually say you know what what in documentation that's attached to this rock right so

that came about in 2005 and that allowed us to start doing that kind of thing and then the first engines appeared somewhere between there in 2008 right and this was framework called scruffles scrubber scrubber which was way back in those days then finally

2008 doctrine2 came along and then doctoring to implemented in no real annotations they really relied heavily on having annotations as one of the options of configuration and that kind of changed the way everyone was looking at annotation because now we had

something that was really part of our day-to-day work being implemented through annotations with with the growth of doctoring too and then sing for me and all the different frameworks using doctrine they decided hey you know what this is something cool it

should be in core so they made a proposal to core can anyone guess what happened to that proposal yeah it was rejected it was heavily jected there was a big yeah very kre jected it actually so now they're the big 5 internals about it because it was new

syntax it yeah it was horrible syntax back then they were still working out the details and all that so it was rejected but it kept on going as a proposal for in doc doc documentation which was then in discussion back in 2011 it has been in discussion since

then no who no real progress have nothing really happened we just you know stayed at that point and then magically just two months ago as I was rewriting my slides or obviously the whole thing kicked off again someone mentioned annotation internals and all

of a sudden everyone was discussing the vision of peach peeps like that much of a fight right so currently we don't have support in core that's okay we have plenty of views and solutions which work but core is still maturing this time around when the

whole discussion happened it was a little bit better it kind of looked like this or it wasn't that cute it got pretty ugly all right but you know it's understandable its new syntax there's a lot of things to take in consideration but this time

[ ... ]

Nota: se han omitido las otras 3.967 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.