Hello I have a project in symfony and I need to do migrations to create tables correctly to the database.
php bin/console doctrine:migrations:migrate
When I run this command to migrate I get en error as
An exception occurred in the driver: could not find driver
how can I fix it?
Related
I have a fresh Laravel 5.6.26 project on my CENTOS 7. After creating the database and setted up the .env file with required information I ran php artisan migrate and exceptions were thrown, however, I can access the database by the Laravel application using Illuminate\Support\Facades\DB and I have the PDO installed.
I am trying to make a laravel and stucked when migration. when i enter php artisan migrate in terminal, showing PDOException error. attaching my screenshot of terminal and phpinfo.
I am laravel dev and now working with Symfony for few days. I have clone a git form bitbucket and wanted to migrate the database. But on laravel we can easily migrate all tables to database I cant find option on Symfony. How can I migrate my tables to mysql? Do I need menually import tables to mysql?
No.
1.Find app/config/parameters.yml:
parameters:
database_host: localhost
database_name: databaseName
database_user: root
database_password: password
2.Create database, with console:
In Symfony 2: php app/console doctrine:database:create
In Symfony 3: php bin/console doctrine:database:create
3.Migrate Tables
In Symfony 2: php app/console doctrine:migrations:migrate
In Symfony 3: php bin/console doctrine:migrations:migrate
Symfony has the bin/console command (in older versions it may be at app/console). If there already is the database and tables, but there are migrations that have not been run, you can run all the available migrations with
bin/console doctrine:migrations:migrate
You can see all the other commands with
bin/console list
or just Symfony commands that deal with database & table creation, migration and more.
bin/console list doctrine
I just cloned a Symfony PHP project from Github but whenever I open a page containing the following code:
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$modules = $em->getRepository('AppBundle:Module')->findAll();
return $this->render('module/index.html.twig', array(
'modules' => $modules,
));
}
The page will return the following error:
ConnectionException: An exception occured in driver: SQLSTATE[HY000] [1049] Unknown database ''.
I am not really experienced with PHP Symfony projects yet and someone asked me to clone this and try to solve the error I will be returned with. Where do I need to look in order to fix the error? I suppose some sort of configuration file which points to database configuration?
This error mean you didn't got access to the database.
Run php app/console doctrine:database:create and after, php app/console doctrine:schema:update --force.
It will create the database on your own local server. (make sure to provide correct connection details on your app/parameter.yml file)
EDIT: Also, don't forget to update your project using composer install and composer update.
Since this is a github project, all dependencies are not pulled
You need to create database:
For Symfony2:
php app/console doctrine:database:create
For Symfony3:
php bin/console doctrine:database:create
You can see sql dump:
For Symfony2:
php app/console doctrine:schema:update --dump-sql
For Symfony3:
php bin/console doctrine:schema:update --dump-sql
Than create tables:
For Symfony2:
php app/console doctrine:schema:create
For Symfony3:
php bin/console doctrine:schema:create
when try to migrate Laravel 4 with table 'user' in database using artisan:
php artisan migrate:make --table="user" CreateUserTable
I receive this error:
C:\xampp\htdocs\laravel>php artisan migrate:make --table=user CreateUserTable
[21.04.2014 02:27:56 NOTICE] Successfully established connection to the database
[21.04.2014 02:27:56 NOTICE] Event Reporting is not allowed at the
moment. Reaso ns: Pre Startup or Post Shutdown
{"error":{"type":"Symfony\Component\HttpKernel\Exception\NotFoundHttpExcepti
on","message":"","file":"C:\xampp\htdocs\laravel\vendor\laravel\framework\
\src\Illuminate\Foundation\Application.php","line":871}}
C:\xampp\htdocs\laravel>
how to solve this?
thanks,
I solved this by install all laravel dependences using composer (not download it from GithHub)
to install all dependencies with composer.
change directory to laravel folder in cmd and than type
composer update
and hit enter and wait until it is done.