bundle does not contain any mapped documents/entities

This will be an error you would see when trying to generate entities or documents using:

app/console doctrine:mongodb:generate:documents YourPathToBundle

Actually the error would also suggest if you have mapping annotation error.

Mostly this could arise from mapping error as suggested.. check if you have @MongoDbDocument in the case of document or the respective @ORMEntity that would tell what that Plain Old Php Object is representing..
btw, the MongoDb and ORM are the aliases, so it could different on your setting..

node js server downloads text/html as file on browser

Those of you who work with webserver, like apache, might already have seen that problem – like the php file that was intended to display content would be downloaded as file.. this has some fix on configuration right..
Now coming to node js, once you install the server like

  1 var http_server=require("http");
  2 http_server.createServer(function(request, response){
  3     response.writeHead(200, {'Content-Type': "text/html"});
  4     response.write("I am listening @port 8896");
  5     response.end();
  6 }).listen(8896);

This should run fine once you run node filename.js where filename.js is the file containing the above code.
but, when you try to run by going to localhost:8896 and in place of seeing the text on your browser, if the browser decided to download the file, give a a careful look at line number 3 to be sure that you have specified correct content type..

Symfony file upload SplFileInfo::get error

Working on Symfony form that has a file upload and got the above error when I try to save it.
The form is build from entity which has the following format:

class MemberFile
{
    /**
     * SymfonyComponentHttpFoundationFileUploadedFile object
     */
    protected $file;
    /**
     * @ORMId
     * @ORMColumn(name="file_id", type="integer")
     * @ORMGeneratedValue(strategy="AUTO")
     */
    protected $fileId;
    
    /**
     * @ORMColumn(type="string", length=255)
     */
    protected $path;
   // additional member variables and getters and setters goes here...
   .....
    public function upload()
    {
        if (null === $this->file)
            return;
        $this->getFile()->move(
                $this->getUploadDir(), $this->file->getClientOriginalName()
        );
        $this->setSize($this->file->getSize());
        $this->setFileType($this->file->guessExtension());
        $this->path=$this->file->getClientOriginalName();
        $this->file=null;
    }
}

And the form is constructed inside the controller in such a way

$member_file=new MemberFile();
        $form=$this->createFormBuilder($member_file)
                ->add("file")
                ->add("save", 'submit')
                ->getForm();

Right after the appropriate action is requested, I called $member_file->upload() after validation to get the above error..

How I solved it..
1. I checked if the file has been properly uploaded despite the error
-> yes it was uploaded
2. Checked if the original tmp file is still intact –
-> NO and BINGO!
Since the file has been moved, the subsequent operations on $this->file can not be done appropriately.
Solution
Just move those operations before you call move file..

    public function upload()
    {
        if (null === $this->file)
            return;
        $this->setSize($this->file->getSize());
        $this->setFileType($this->file->guessExtension());
        $this->path=$this->file->getClientOriginalName();
        $this->getFile()->move(
                $this->getUploadDir(), $this->file->getClientOriginalName()
        );
        $this->file=null;
    }

Call to a member function format() on a non-object Symfony datetime error

When you assign time for datetime in you Entity in Symfony project, you might get this problem. The fix is simple.
If you have your entity column setup as Date or datetime like

@ORMColumn(name="date_created", type="datetime", nullable=false)

The respective setDateCreated() method expects standard datetime object.
So,

$entity->setDateCreated(new DateTime());

will solve the problem. If you want to give different time other than today’s date, then you can populate DateTime object and provide that

Unserialize giving errors at offset in php

Serialization in PHP is as easy as using serialize function. But to use the serizalized one, we need unserialize(). When you use this if you get an annoying notice of error at offset or something do this

$unserialized_value=@unserialize($serialized_value);
if ($unserialized_value)
{
    //enjoy the unserialized value here.
}

Mind you it won’t be a road blocker after all it is just a notice – but.. just cleaner is better

symfony production path not working but works on dev environment

If you are working on the symfony and testing the changes, and you want to look at how it looks on the production env by just changing the url.. and if you are not seeing your current changes – most probably it is caching issue:
do the following being in your symfony project..

php app/console cache:clear --env=prod --no-debug

That is it

The dist file “app/config/parameters.yml.dist” does not exist. Check your dist-file config or create it.

Are you upgrading symfony to 2.3. Bum! This will be the problem you would face after upgrading the composer.json file and trying to do 

composer.phar install 

the solution is simple. Just copy the existing parameters.yml file from app/config/ folder to new file called parameters.yml.dist and rerun the command

Single id is not allowed on composite primary key in entity Doctrine error

You might get the above error on PHP Doctrine

if you got the above error, then it means you have two or more ids as primary in your object representing the table.

Example:

class Member
   /** @id 
    * @Column(type="integer") 
    * @GeneratedValue(strategy="AUTO")
    */
   private $id;
   /** @id @Column(type="string") */
   private $key;
...

The above declaration would create the above error and taking out the generatedValue part can resolve the issue.

See the solution to common error of new entity was found though relation while using doctrine