I'm using Symfony 4 and MongoDB with docker and i want to save a new document (only one) on my database but multiple entries are inserted.
.env file :
PROJECT_DIR=/var/www/movies
APACHE_PORT=8080
PHP_PORT=9000
MONGODB_USER=test
MONGODB_PASSWORD=test
MONGODB_HOST=mongo
MONGODB_PORT=27017
MONGODB_DB=movies
MONGODB_URL=mongodb://${MONGODB_HOST}:${MONGODB_PORT}
doctrine_mongodb.yaml:
doctrine_mongodb:
auto_generate_proxy_classes: true
auto_generate_hydrator_classes: true
connections:
default:
server: '%env(resolve:MONGODB_URL)%'
options:
username: '%env(resolve:MONGODB_USER)%'
password: '%env(resolve:MONGODB_PASSWORD)%'
default_database: '%env(resolve:MONGODB_DB)%'
document_managers:
default:
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Document'
prefix: 'App\Document'
alias: App
Controller index function:
/**
* @Route("/", name="base")
*/
public function index(DocumentManager $dm)
{
$movie = new Movie();
$movie->setTitle("Test");
$dm->persist($movie);
$dm->flush();
return $this->render('base/index.html.twig');
}
Finally, i resolved the problem. I commented the following line that was hanging on my base.html.twig, which was calling again the localhost.
{# <link rel='stylesheet' id='quick-preset-css' href='{{ asset('') }}' type='text/css' media='all' />#}