unable to connect with database - symfony

I have downloded some code of symfony from github. I have configured all the things.
I have created the database using command
php app/console doctrine:database:create
I have created the database also but when I am trying to log in or register then I am not registering when I am looking at profiler then it shows that no query has been executed. what should I do ?

Check your parameters_dev.ini file inside config and confirm whether the setting s are correct or not ? have you already created the database? can you upload some more code for details?

Check your port and try type 127.0.0.1 instead of localhost in parameters file, it's strange but it works for me.

Did you create the schema after you created the database?
php app/console doctrine:schema:create
What do the logs (app/logs/dev.log or app/logs/prod.log) say?

Related

Symfony - can't work out where DB config is being loaded from

I must be doing something stupid, but I just can't work it out.
I'm running a Symfony project which is connecting to a Postgres DB on different machine on the local network. The Postgres database details are currently defined in .env and work as expected. I want to move to using Symfony 'secrets' and remove the user/pw details from .env
Whilst testing, I ended up removing .env altogether and also removing the secret, yet the webpage is still successfully loading all the data from the DB. I'm now trying to work out why it is still working. Are the DB details cached somewhere on the server? Where else could they be loading from?
It can be the cache (configurations are also cached), use bin/console cache:clear to be sure.
Make sure you Server does no define the env variables by it self. Some server do not load the env variable from the env file. Instead you have to define them explicit in the server configuration.

Symfony doesn't find pdo_sqlsrv driver

I have one problem with Doctrine (or with my server configuration, I don't know where is the problem) in my Symfony2 web. I have been looking for an answer since several days but I haven't found it yet.
I need to connect my symfony web to a remote Microsoft SQL database through Doctrine. For this reason, I have added the "database_driver: pdo_sqlsrv" param in app/config/parameters.yml, but when I try to execute (in my Mac) a command like:
php bin/console doctrine:database:create
or
php bin/console doctrine:generate:entities AppBundle/Entity/Product
I get the following error:
[Doctrine\DBAL\Driver\PDOException] could not find driver
[PDOException] could not find driver
I have checked the phpinfo and the driver doesn't appear (only mysql, sqlite). I don't know if it's possible to add MSSQL, because in Microsoft SQL Server Functions (PDO_SQLSRV) appears that it needs to be running on a Windows.
Is not possible to access a mssql database without Windows? (If yes, how can I do it).
Would I need a Windows hosting?
Thanks in advance.
I'm using sql server on my last project.
here is what i've done to make it work on my dev environment
install pdo-dblib
composer require leaseweb/doctrine-pdo-dblib
configure doctrine to use the driver_class from the lib above instead of refering the sql_serv driver
driver_class: Lsw\DoctrinePdoDblib\Doctrine\DBAL\Driver\PDODblib\Driver

How to reset a meteor project thats been deployed with meteor up

I have used meteorUp here sucesffuly to deploy my meteor project on my own host.
However I have no idea how to reset the database, or the entire project itself, like I can locally with the simple meteor reset command. I tried installing meteor on the server but there is no .meteor project so that command doesnt work. I looked in /opt/meteor folder but no meteor project exists.
If you need to reset the data. You need to login to the server. login to mongodb with mongo meteor.
Then do db.dropDatabase() to delete the DB.
If you need to change the app, simple redeploy should work.
BTW: Do you not use MongoDB this way for a production app.
If you are using mup or mupx try:
Login to your server:
$ ssh <user>#<server-ip>
Login into mongo shell
$ docker exec -it mongodb mongo <app-name>
Drop db
> db.dropDatabase()
Is this what you are looking for?
mup reconfig
Based on the doc for it:
This will also restart the app [without re-deploying], so you can use it for that purpose
even if you didn't change the configuration file.
I don't have enough points to comment yet, but to add onto Arunoda's response, you might want to
use [name of app database]
before you
db.dropDatabase()
And if you don't know what the name is you can also
show databases
If you used mup, the database will generally be the same name as your app.

How to forward request logs to console in Symfony? Now logs are saved to a file

I run the server in cmd with this command in Symfony. And it says that the server is running:
C:\xampp\htdocs\projects\vs\ge>php app/console server:run
Server running on http://127.0.0.1:8000
And that's all. No any log info is sent to console when I make page reloads. All logs are saved to a file. But I want to forward logs to console, like it is done in Node.js for example. How to set it in Symfony2?
The thing is, when you run this command (which is not really recommanded by the way, as it is not as powerful as a server running with Apache or Nginx for example), when you execute your script (going on http://localhost for example), it is not aware that it is running on a php server.
But, I guess that if you really want some logs, maybe you should extend the symfony command and add some logs there ?
Here you will find a nice solution:
http://symfony.com/blog/new-in-symfony-2-4-show-logs-in-console

Symfony2 Doctrine database into production

Sorry if the question is one of a newb.
When I deliver my symfony2 website to my production webserver. I'm using a low cost hosting service. I cannot access mysql remotely ( only execute statement from their website through phpmyadmin ).
Case 1: Assuming I could access remotely, i should run:
php app/console doctrine:schema:create --env=prod
with appropriate database settings so it would update my db.
Case 2: Assuming I can't access remotely, then i have two option:
I could create an ugly script that would call the above line from the website and remove it after delivery.
I could get the sql statement printed to a file and execute it. Which seems better to me.
Question:
Is there a pb with the above ?
Is there a way to get an sql script in a file from:
php app/console doctrine:schema:create --env=prod
You can dump the sql statement using the --dump-sql option, and store it in a file:
php app/console doctrine:schema:create --dump-sql > statement.sql

Resources