AWS, DigitalOcean User Data for Apache, PHP, MongoDB, Git

User Data

I’m using user data scripts for both my AWS servers and DigitalOceal servers. Even if I only need to install a few thing, I use user data not to lose time for installing process. Here is the user data that I mostly use.

Install PHP – MongoDB Driver Ubuntu 14.04 LTS

Details for AWS

Details for DigitalOcean

Using MongoDB Embedded Documents in Symfony with Doctrine

I’m using embedded documents to handle team accounts. We have a main team account information and also team members’ information in a sub-array of same document. We aim to log users in with using company’s username/password or their own username/password.

You need to be familiar with those to understand the concept

  • MongoDB
  • Embedded Documents
  • Symfony
  • Doctrine ODM

Data

Here is an example user document structure,

 

We will use Doctrine MongoDB Bundle to use MongoDB with Symfony. So if you have not installed it follow steps here: http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html

User Document Class

We need to create a document class which describes our MongoDB document. This will hold our data for our operations. And we also use automatically generated get() and set() methods for the values which we have in our document class. In short, create your MongoDB document as a PHP class with needed defining (annotations) for data types, or other options.

TeamMembers Embedded Document Class

After creating our main document’s class and point the embedded document class, we need to create TeamMembers class as same as our User class.

Getters and Setters

To generate get and set methods for our document classes, run this command in your Symfony directory.

This will update our src/MyProjectBundle/Document/TeamMembers.php and src/MyProjectBundle/Document/User.php classes with generated get and set methods. Annotations will also be generated with methods.

Here is a few examples for getter and setter methods,

Controller

To create a new document with its embedded document, we need to create new object for each one and use set() methods to set their values. After that we need to combine them with add method.

Create new document

Get document

Full controller

 

Example might not work as expected. Use it as draft.

Hello world!

Sorun şu ki,
Teknoloji yazılarının ömrü yeni versiyonu çıktığında doluyor.
Yemek yazılarının ömrü senden sonraki müşterinin yaşadığı deneyimle doluyor.

Bugün hiç kimse MongoDB 2.6’nın kurulum notlarını aramıyor. Yarın hiç kimsenin 3.2’yi aramayacağı gibi.

Haliyle, teknoloji veya deneyim yazarak işe yaramak zor.

Çözüm şu olabilir,
Her şeyi versiyonlayarak mümkün mertebe geriye dönerek güncelleme yaparsak, hem hızlı tükenen ve değişen bilgiyi, hem de deneyimi işe yarar halde tutabiliriz. Bunu yapabildiğimiz hibrit yapılı wiki-blog mantığı, algısı ve mimarisine ihtiyacımız var.

Velhasıl, denemeye değer.