Connecting Laravel to Sqlite in Laravel 5.2 - sqlite

How can I connect to Sqlite db?
I have done the below things
1) Created project.
2) Created database.sqlite inside the database folder (database\database.sqlite).
3) Changed 'default' => env ('DB_CONNECTION', 'mysql'), to 'default' => env ('DB_CONNECTION', 'sqlite'), in the database.php file.
4) Ran php artisan migrate.
But I am getting an error
[InvalidArgumentException]
Database (sqlite) does not exist.
Then I tried DB_DATABASE=database\database.sqlite as stated in the documentation but I get the following error.
[PDOException]
Could not find driver
I have set the .env file as below
DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database/database.sqlite
DB_USERNAME=homestead
DB_PASSWORD=secret

Sqlite is available for the CLI, but not for PHP. You need to install it.
Run the below command in terminal
$ sudo apt-get install php5-sqlite
If you're running php7, you need to install php7.0-sqlite.
After that restart your apache or whatever web server you have.

Related

Launch project symfony in browser [duplicate]

I have installed Lampp on my linux system, and I am learning symfony2, while trying to create the schema with symfony2 command
php app/console doctrine:schema:create
I am getting the following error message:-
PDOException “could not find driver”
I also uncomment this line extension=php_pdo_mysql.dll in php.ini file
I tried to look and google my issue but couldn't resolve my problem. when i run php -m command i am getting the following result:-
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mhash
openssl
pcntl
pcre
PDO
----
----
Is there a way i can remove this issue ?
In Ubuntu, write in the console
sudo apt-get install php5-gd php5-mysql
and it will work
Hope you are running your project in localhost. In your project folder app/config a file named parameters.ini , Make sure that your Mysql database connection cofiguration is correct. If you are using mysql See database_driver=pdo_mysql is its driver.
Below is an example.
database_driver = pdo_mysql
database_host = localhost
database_port =
database_name = databasename
database_user = msqlusername
database_password = mysqlpassword//if not make blank
mailer_transport = smtp
mailer_host = localhost
mailer_user =
mailer_password =
locale = en
secret = ThisTokenIsNotSoSecretChangeIt
Hope it helps you.
You need to have a module called pdo_mysql.
Look for the following in phpinfo() output,
pdo_mysql => PDO Driver for MySQL, client library version => 5.1.44
to install pdo_mysql you need to do this:
pecl install pdo
pecl install pdo_mysql
and then add the following to your php.ini file:
extension=pdo.so
extension=pdo_mysql.so
brew install php70-pdo-pgsql
in case you installed php7 on mac with brew and, change php version according to what you have installed.
if you are using XAMPP then in php.ini file line no 897(depends on version),
;extension=php_pdo_pgsql.dll
uncomment it , then it appears like below
extension=php_pdo_pgsql.dll
in php.ini file line no 897, then restart XAMPP.
There are two PHP versions installed in my server PHP 5.6 and PHP 7
When I run the command php app/console doctrine:schema:update I have the error : [PDOException] could not find driver
I resolve this error by specifying the PHP version:
php5.6 app/console doctrine:schema:update
Looks like your install is missing the .so files it needs to implement the mysql connection. If you're using a package management system to install PHP then make sure you've installed all the necessary submodules (in this case I think you'll need mysql-dev, and the various PHP PDO modules), though such dependencies should have been resolved for you by the package manager.
If you didn't go through a package manager, then you'll have to compile the required .so files from source.
I had the same problem and for me, it was having multiple PHP versions.
So specifying the full address of the PHP solved the problem.
Adding to Jaspreet Chahal's answer.
When installing PDO as a shared module, the php.ini file needs to be updated so that the PDO extension will be loaded automatically when PHP runs. You will also need to enable any database specific drivers there too; make sure that they are listed after the pdo.so line, as PDO must be initialized before the database-specific extensions can be loaded. If you built PDO and the database-specific extensions statically, you can skip this step(Source).
What I mean is, it should look something like this -
extension=pdo.so should be placed before the extensions of the different database drivers.
Maybe you forget to install doctrine/dbal
composer update
composer require doctrine/dbal
if it didn't work go to your php.ini (according to current version)
and remove ";"
;extension=pdo_mysql.so

How to install symfony2 project existing in github repository to local instance

I'm having a symfony2 project in github repository. I want to install it to my local instance. I'm using Xampp on Windows 7. How can I achieve it?
Thanks!!
if your using xampp the easiest way is to use symfony build in server.
clone or download the symfony project to your xampp htdocs.
start your xampp and open the shell, (shell button on the right)
locate yourself in the root symfony dir. and type:
php app/console server:run
a local php server should start on http://localhost:8000
i recomment using this because (dev mode is loaded by default).
its faster then a VM because you dont sync files.
you can also add verbose arguments
php app/console server:run -vvv
that way you get more output info when debugging.

Drush. Command pm-enable needs a higher bootstrap level to run

I have started to learn Drupal on this week and I have installed the drush on my virtual machine with CenOS ( Drupal version: 7.28, Drush version: 7.0-dev). I installed drupal using drush by command: drush dl --drupal-project-rename=mysite
and downloaded some moduls by command: drush dl admin_menu ctools views ...
But when I want enable these moduls in Drupal by command: drush en -y admin_menu_toolbar ...
I have errors:
Command pm-enable needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to[error]
run this command.
The drush command 'en admin_menu' could not be executed. [error]
Drush was not able to start (bootstrap) the Drupal database. [error]
I changed the code in the file /sites/default/settings.php
'host' => 'localhost', to
'host' => php_sapi_name() == 'cli' ? '127.0.0.1' : 'localhost',
but it still does not work.
Tell me please how can I fix it?
If I use command "drush si standard --db-url=mysql://user:password#localhost/db_name" database is create and drupal install. But when I try to sign in using provided username and password server answer me "404 Not found".
Pictures:
http://gyazo.com/c34c2f361d1675d6df42b909d7eded09
http://gyazo.com/a118b2e370b79103046f21e50f955b2f
Just running drush dl --drupal-project-rename=mysite will not install drupal for you. Only download the source.
Running drush si standard --db-url=mysql://user:password#localhost/db_name will install it for you.
Alternatively you can add --account-pass=somepassword to set the user 1 pass directly when installing.
Remember to change the --db-url to suit your setup.
After that is done, be sure you stand in the project when you run drush commands.
In my case it turned out that I needed to install mysql-client:
apt-get install mysql-client
I had the following situation:
drush 4, 5 and 6 worked fine for me.
drush 7+ didn't work (different errors, including that ones you're describing).
And my MySQL database was located on a separate server.
HTH,
Alexander

Meteor SyntaxError after bundling

My meteor application works locally. When I bundle it (using meteor bundle myapp.tgz), upload it on my server and launch it, I have the following error upon opening the page on Chrome console:
Uncaught SyntaxError: Unexpected token <
On Firefox console:
SyntaxError: syntax error
[Break On This Error]
<!DOCTYPE html>
In order to try to find the origin of the error, I used an old bundle that was working. I can see the problem is that the files in static_cachable are not found.
Meteor is still trying to use the files from the old bundle.
If I rename the new bundled files in static_cachable to the old name then It works.
I checked in all files contained by the root of the bundle folder and references are correct (they are pointing to the new names).
It there some cache somewhere that keep the reference to the old static_caches files ?
To avoid the error, one has to restart Meteor after deployement :
rm -rf bundle
tar -zxf myapp.tar.gz
cd bundle/server/node_modules/
rm -r fibers
npm install fibers#1.0.0
export PORT=32632
export MONGO_URL=mongodb://meteor:**#localhost:18700/moviegrid
export ROOT_URL='mydomain.com'
nohup node bundle/main.js &
Look at the javascript console when you load your app locally and check if there is no error. If there is some, correct them before bundling/deploy.
This may not be your problem but according to http://docs.meteor.com/#deploying:
For now, bundles will only run on the platform that the bundle was created on. To run on a different platform, you'll need to rebuild the native packages included in the bundle. To do that, make sure you have npm available, and run the following:
$ cd bundle/server/node_modules
$ rm -r fibers
$ npm install fibers#1.0.0
Consider installing meteor on your server, cloning your app directory and using meteor run inside the directory to see if the app runs in development on the server.
If it successfully launches in development then bundle it on the server and use those files. Or just run with meteor --production

Change CLI's php

Im working with Symfony2. Im trying to execute the following command:
php app/console doctrine:database:create
The problem is that I get the following error:
PHP Warning: PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/no-debug-non-zts-20090626/apc.so' - dlopen(/opt/local/lib/php/extensions/no-debug-non-zts-20090626/apc.so, 9): image not found in Unknown on line 0
Could not create database for connection named <comment>symfony</comment>
could not find driver
APC is already installed, since the Symfony/web/config.php was OK, what I realised is that the version of php from CLI is different from the one Apache is running.
The one Apache is running has APC installed, so I would like CLI to run that same php, How can I do that?
in my case deleting the version that macports installed was enough to have CLI and Apache run the same PHP.
And that's:
sudo port uninstall php5

Resources