I am currently working on a Symfony 2 project that creates iCalender events which get sent out to recipients via email. I first hacked my own event script but after reading the RFC specifications I then realized how involved the protocol was – So I did a quick search on github and came across a nice php library which already handles most of the events specified in RFC document. (Do not re-invent the wheel unless the wheel is your business)
The library I found is called sabre-vobject which has some documentation to get you started creating your first event with minimal effort and fortunately it already supports composer and php namespaces already.
Now there is no bundle on knpbundle.com which deals with iCalender events currently which was the first place I checked, However since sabre-vobject library supports composer and php namespaces it becomes easy adding it to your Symfony 2 project.
add the library to your project’s composer file, please see the attached screenshot below.
You can perform your composer update there after and all is well.
Lets make the Vcalender class available as a service in our application, I prefer using JMSDiExtraBundle for all my dependency injection needs, but to configure this particular service I will use the services.xml approach because I do not want to add JMSDiExtraBundle annotations on the class in the vendor directory nor do I see a need to create another class to extend the original sabre-vobject VCalender class, Any ways see the xml configuration on the attached screenshot.
After you have done that, you can run a quick container debug to check if your service is appearing. After you have located your service in the container debug it’s time to test the service.
Thanks for reading, Bye.