So a system without using a database is rare and I'd suggest if you are thinking of you are thinking of using symfony for a flat website, you rethink.
install mysql
sudo apt-get install mysql-server
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
sudo service apache2 restart
MYSQL -u root -p
and you chould be in mysql
quit
I'd suggest installing workbench for dev - https://dev.mysql.com/downloads/workbench/
Once installed set up a new connection
Go to your VMware server and into the command line type:
ifconfig
look for 192.168.XX.XXX
and copy that into Hostname.
enter the user and password
In workbench create a schema (left click on the schemas section). ok your done in workbench
Now the next bit is for using Doctrine:
best practice is you store config information in the envars of apache. Not in the code.
sudo nano /etc/apache2/envars
export BASIC_DB_USER=myUsername
export BASIC_DB_PASSWORD=myMySqlPassword
export BASIC_DB_PORT=3306
export BASIC_DB_NAME=mySchemaName
This enables use of the data inside the symfony project.
But this wont help us run commands for doctrine on the command line so we need to add the same things for php cli to pick up.
sudo nano /etc/environment
export BASIC_DB_USER=myUsername
export BASIC_DB_PASSWORD=myMySqlPassword
export BASIC_DB_PORT=3306
export BASIC_DB_NAME=mySchemaName
Now you can run commands in doctrine to built entities and SQL tables.
So for example already set up on this example (from github) :
go to command line and type:
php bin/console doctrine:schema:validate
- here you should get feed back on wether doctrine can see the database based on your parameter.php sttings.
- for trouble shooting try dump($container->getParameter('database_port')); or un hashing the code in parameters.php.
php bin/console doctrine:generate:entity
and follow the instructions
then try
php bin/console doctrine:schema:update
great huh. the database is upadated with the entitiy you just created!