NotionCommotion Posted February 1, 2019 Share Posted February 1, 2019 Finally getting around to giving Doctrine a try. Looks like YAML is depreciated, so my choices are DocBlocks or XML. I am sure it is personal choice, however, I would like to start off with what most feel is the best path. Any recommendations? Thanks Quote Link to comment Share on other sites More sharing options...
kicken Posted February 2, 2019 Share Posted February 2, 2019 I'd go XML. Keep in mind that DocBlocks are just comments, and in theory one should be able to strip out comments without affecting how a script works. Doing mappings and other things inside the DocBlock is turning your comments into code that is essential for your script to operate. This can cause problems in some instances such as if you use an opcache that doesn't preserve comments. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted February 2, 2019 Author Share Posted February 2, 2019 24 minutes ago, kicken said: I'd go XML. Keep in mind that DocBlocks are just comments, and in theory one should be able to strip out comments without affecting how a script works. Doing mappings and other things inside the DocBlock is turning your comments into code that is essential for your script to operate. This can cause problems in some instances such as if you use an opcache that doesn't preserve comments. Thanks kicken, I was starting to lean that way. The thought of having the schema so dependent on some PHP script scares me. What do you think about Doctrine? While I think some aspects are great, it just seems that it degrades the databases integrity. Yeah, more I think of it, definitely XML over DocBlocks. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted March 26, 2019 Author Share Posted March 26, 2019 I've been using XML for Doctrine's metadata, and I soon after started using Symphony's serializer, and continued on the XML path. I still dislike the idea of the database schema being dependent upon comments in a PHP file, but am starting to question whether it might be worth using DocBlocks. One issue with XML is the lack of documentation as most of both Doctrine and the serializer focused on DocBlocks, however, by cross-referencing the various documents, one is able to connect the dots. Another issue is making a modification to the Doctrine XML file required changing the classes, however, I created a small script which uses Doctrine's class builder and to create new classes and then edit the class files to make my desired modifications, and this is not a big deal. A third issue is needing to focus on three separate files at the same time (the entity class, doctrine XML, and serializer XML) which is a bigger issue than I would have expected. Any thoughts how to make this easier? Using a single XML document for both the Doctrine and serializer definitions would definitely help, but I don't think this is possible. Locating them in the same directory might help a little since they will be located next to each other, but wouldn't help much and might create other issues. I guess I could get a third monitor, but my work space is somewhat limited in space. Any other ideas? Quote Link to comment Share on other sites More sharing options...
kicken Posted March 26, 2019 Share Posted March 26, 2019 If you don't mind the whole comments are now code thing then feel free to use them. Just remember to set opcache.save_comments=1 if you use opcache. Since annotations are popular that is the default. For whatever reason using annotations in docblocks has become really popular and it is indeed much easier overall to just follow the trend. As you've noticed it can be harder to find information about other methods. I've run into that many times with symfony because I do everything via YAML configuration but it seems most of the internet only cares about docblock annotations. Ive had to go digging into the source a few times to find the yaml equivalent of a few annotations. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted March 26, 2019 Author Share Posted March 26, 2019 Thanks kicken, I want to resist doing so, but it is tempting. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.