Symfony - Driver are mandatory if PDO instance - composer-php

I have a project in Symfony 2.1
I'm trying to run Composer install and it gives me this error:
The options 'driver' or 'driverClass' are mandatory if PDO instance is
given to DriverManager :: getConnection ().
The system is:
Mac OS Sierra 10.12.6 (16G29)
PHP 7.0.22 (cli) (built: Sep 14 2017 09:01:19) (NTS)
Composer version 1.2.2
The Database configuration in Symfony in parameters.yml:
parameters:
     database_driver: pdo_mysql
     database_host: 127.0.0.1
     database_port: ~
     database_name: myDatabaseName
     database_user: myDatabaseUser
     database_password: myDatabasePassword
What is the problem?

Related

php artisan migrate throws received invalid response to SSL negotiation

I have a laravel app on nginx with postresql
php artisan migrate
throws error:
In Connection.php line 671:
SQLSTATE[08006] [7] received invalid response to SSL negotiation: b (SQL: select * from information_schema.tables where table_schema = publ
ic and table_name = migrations and table_type = 'BASE TABLE')
In Connector.php line 70:
SQLSTATE[08006] [7] received invalid response to SSL negotiation: b
FILES:
.env
...
DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=secretdbname
DB_USERNAME=secretusername
DB_PASSWORD=secretpassword
...
postresql.conf
...
port = 5432
...
in php.ini enabled:
pgsql
pdo_pgsql
mbstring
php -m
...
mbstring
openssl
PDO
pdo_mysql
pdo_pgsql
pgsql
...
Appropriate db exists, user exists and has got all the privileges.
Postgres service is active.
DB and app are located on the same server.
What I have tried:
setting up a different port in both .env and postgres.conf
tested with a different db, user and password
restarted postresql
in tinker DB::connection()->getPdo(); throws the same error
in DB_HOST tried 127.0.0.1. instead of localhost
in config/database.php i tried setting 'sslmode' to 'disable'
I have SSL certificate with certbot.
I would appreciate some hint on how to solve the above error.
Indeed, following Alex running
php artisan config:cache
helped, as it thrown a slightly different error which pointed me to the actual solution
SOLUTION:
postgresql.conf file has got this line:
listen_addresses = 'localhost'
commented by default, thus the solution is simply to uncomment it (as I mentioned in my original post, both DB and app are on the same server).
Hope it will save sb's time for the future.
I got the same error today with the Laravel 9.
The solution was to make sure the Postgress DB_Port inside .env is pointing to 5432.
Hope it will help others.

how to solve the following error while creating new laravel project

i am new to homestead and laravel , i am trying to install homestead and start new laravel proeject , i follow the steps in the following link , https://www.youtube.com/watch?v=Il08--droNI, it seems that i succeed to install homestead then i started
vargant up
and installed the laravel inside my Homestead folder using the following command
composer global require laravel/installer
now i am trying to start the new project using the following command
laravel new blog
but it gives me the following errors
Crafting application...
PHP Warning: file_put_contents(/home/vagrant/code/laravel_816486aaffc1239c550dccbdbf28f281.zip): failed to open stream: Permission denied in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 147
Warning: file_put_contents(/home/vagrant/code/laravel_816486aaffc1239c550dccbdbf28f281.zip): failed to open stream: Permission denied in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 147
PHP Warning: ZipArchive::extractTo(): Permission denied in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 169
Warning: ZipArchive::extractTo(): Permission denied in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 169
PHP Warning: ZipArchive::close(): Invalid or uninitialized Zip object in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 171
Warning: ZipArchive::close(): Invalid or uninitialized Zip object in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 171
You should verify that the "storage" and "bootstrap/cache" directories are writable.
In Process.php line 332:
The provided cwd "/home/vagrant/code/myproject" does not exist.
new [--dev] [--auth] [-f|--force] [--] [<name>]
vagrant#homestead:~/code$ ^C
here is my .yaml file
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
folders:
- map: C:\Users\hit-ham\laravel-apps
to: /home/vagrant/code
type: "nfs"
sites:
- map: myproject.test
to: /home/vagrant/code/myproject/public
databases:
- homestead
features:
- mariadb: false
- ohmyzsh: false
- webdriver: false
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
my Homestead folder is in users/myname
edit: i tried to remove everything and setup new windows , and start everything from the begining , installing vagrant , virtual box , composer, but i have now new error
Crafting application...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for league/flysystem 1.0.67 -> satisfiable by league/flysystem[1.0.67].
- league/flysystem 1.0.67 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
Problem 2
- league/flysystem 1.0.67 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
- laravel/framework v7.6.2 requires league/flysystem ^1.0.8 -> satisfiable by league/flysystem[1.0.67].
- Installation request for laravel/framework v7.6.2 -> satisfiable by laravel/framework[v7.6.2].
To enable extensions, verify that they are enabled in your .ini files:
- C:\php7\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
or in windows with IIS
extension=php_fileinfo.dll
In the php.ini file, uncomment the following line extension = fileinfo

How can I create a laravel 5 dev site with DDEV?

How can I create a laravel 5 dev site with DDEV ? (see https://github.com/drud/ddev/issues/898#issuecomment-463203604)
I created a Laravel 5 dev site on Win10 using DDEV and Docker Desktop with Linux containers. Note that it was not necessary to install composer on Win10 since composer installed by DDEV in the web container was used instead.
Here are the steps:
Created a d:\laravel5 folder
Opened a PowerShell window as administrator and switched to this folder
Ran ddev config and selected the default "php" project type:
PS D:\laravel5> ddev config
Creating a new ddev project config in the current directory (D:\laravel5)
Once completed, your configuration will be written to D:\laravel5\.ddev\config.yaml
Project name (laravel5):
The docroot is the directory from which your site is served.
This is a relative path from your project root at D:\laravel5
You may leave this value blank if your site files are in the project root
Docroot Location (current directory):
Found a php codebase at D:\laravel5.
Project Type [drupal6, drupal7, drupal8, wordpress, typo3, backdrop, php] (php):
Project type has no settings paths configured, so not creating settings file.
Configuration complete. You may now run 'ddev start'.
Instrumentation is opted in, but SentryDSN is not available.
Instrumentation is opted in, but SegmentKey is not available.
PS D:\laravel5>
DDEV created a d:\laravel5\.ddev folder that will be modified with the addition of 4 files before running the ddev start command.
Note that for the DDEV "php" project type, the Laravel 5 PHP prerequisites are all satisfied
PHP >= 7.2.0
BCMath PHP Extension
Ctype PHP Extension
JSON PHP Extension
Mbstring PHP Extension
OpenSSL PHP Extension
PDO PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Created the file .ddev\config.laravel5.yaml with content
docroot: blog/public
Created the file .ddev\docker-compose.laravel5.yaml with content
version: '3.6'
services:
web:
environment:
- DB_HOST=db
- DB_PORT=3306
- DB_DATABASE=db
- DB_USERNAME=db
- DB_PASSWORD=db
Created the file .ddev\nginx-site.conf with content
# ddev default config
# You can override ddev's configuration by placing an edited copy
# of this config (or one of the other ones) in .ddev/nginx-site.conf
# See https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#providing-custom-nginx-configuration
## Set https to 'on' if x-forwarded-proto is https
#map $http_x_forwarded_proto $fcgi_https {
# default off;
# https on;
#}
server {
listen 80;
server_name laravel5.ddev.site;
# The WEBSERVER_DOCROOT variable is substituted with
# its value when the container is started.
root $WEBSERVER_DOCROOT;
include /etc/nginx/monitoring.conf;
include /mnt/ddev_config/nginx/*.conf;
}
Created the file .ddev\nginx\laravel5.conf with content:
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
## Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
#sendfile off;
error_log /dev/stdout info;
access_log /var/log/nginx/access.log;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
#fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
Ran ddev start:
PS D:\laravel5> ddev start
Starting laravel5...
Using custom nginx configuration in nginx-site.conf
Using custom nginx partial configuration: [D:\laravel5\.ddev\nginx\laravel5.conf]
Custom configuration takes effect when container is created,
usually on start, use 'ddev restart' if you're not seeing it take effect.
Creating volume "laravel5-mariadb" with default driver
Building db
Building web
Creating ddev-laravel5-db ... done Creating ddev-laravel5-dba ... done Creating ddev-laravel5-web ... done
ddev-router is up-to-date
Successfully started laravel5
Project can be reached at https://laravel5.ddev.site https://127.0.0.1:32789
Instrumentation is opted in, but SentryDSN is not available.
Instrumentation is opted in, but SegmentKey is not available.
PS D:\laravel5>
Ran ddev ssh and executed the following shell commands in the web container
cd /var/www/html
composer create-project --prefer-dist laravel/laravel blog "5.8.*"
The output was as follows:
freefall322#laravel5-web:/var/www/html$ cd /var/www/html
freefall322#laravel5-web:/var/www/html$ composer create-project --prefer-dist laravel/laravel blog "5.8.*"
Installing laravel/laravel (v5.8.35)
- Installing laravel/laravel (v5.8.35): Loading from cache
Created project in blog
> #php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 80 installs, 0 updates, 0 removals
- Installing symfony/polyfill-ctype (v1.12.0): Loading from cache
- Installing phpoption/phpoption (1.5.0): Loading from cache
- Installing vlucas/phpdotenv (v3.6.0): Loading from cache
- Installing symfony/css-selector (v4.3.4): Loading from cache
- Installing tijsverkoyen/css-to-inline-styles (2.2.1): Loading from cache
- Installing symfony/polyfill-php72 (v1.12.0): Loading from cache
- Installing symfony/polyfill-mbstring (v1.12.0): Loading from cache
- Installing symfony/var-dumper (v4.3.4): Loading from cache
...
(skipping many lines of output)
...
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0)
phpunit/phpunit suggests installing ext-xdebug (*)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover --ansi
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
> #php artisan key:generate --ansi
Application key set successfully.
freefall322#laravel5-web:/var/www/html$
Navigated to the newly created Laravel 5 dev site
Added a route to blog/routes/web.php in order test the database connection (code was from https://stackoverflow.com/a/44004752)
Route::get('/foo', function () {
//
try {
DB::connection()->getPdo();
if(DB::connection()->getDatabaseName()){
echo "Yes! Successfully connected to the DB: " . DB::connection()->getDatabaseName();
}else{
die("Could not find the database. Please check your configuration.");
}
} catch (\Exception $e) {
die("Could not open connection to database server. Please check your configuration.");
}
});
The result was Yes! Successfully connected to the DB: db
Note: to install latest version of Laravel, instead of
composer create-project --prefer-dist laravel/laravel blog "5.8.*"
remove the version specifier and just use
composer create-project --prefer-dist laravel/laravel blog
I tried this today and it installed Laravel 6.0
You can create a Laravel 5 dev site using ddev as below:
mkdir projectName
cd projectName
ddev config --project-type=laravel --docroot=public --create-docroot
ddev start
ddev composer create --prefer-dist laravel/laravel:5.8.*
ddev exec "cat .env.example | sed -E 's/DB_(HOST|DATABASE|USERNAME|PASSWORD)=(.*)/DB_\1=db/g' > .env"
ddev exec "php artisan key:generate"
ddev launch
See the ddev Laravel quick start documentation.

symfony2 oci connect doctrine

I have configure Oci & PHP and runs correctly. When I run php file for connect to Oracle using php works fine.
When I run php app/console doctrine:mapping:import, the entities are discovered and the entity file exists with the table's fields, but when I try to browser to http://localhost/app_dev.php shows me:
DEBUG - oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and LD_LIBRARY_PATH are set and point to the right directories DEBUG - oci_connect(): Error while trying to retrieve text for error ORA-01804 CRITICAL - Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occured in driver: " at /var/www/html/proyecto3/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php line 76
My configuration files are:
config.yml
> doctrine:
> dbal:
> driver: oci8
> host: "%database_host%"
> port: "%database_port%"
> dbname: "%database_name%"
> user: "%database_user%"
> password: "%database_password%"
> charset: UTF8
parameters.yml
> parameters:
> database_host: 192.168.59.148
> database_port: 1521
> database_name: BRULO001
> database_user: scott
> database_password: scott
> mailer_transport: smtp
> mailer_host: 127.0.0.1
> mailer_user: null
> mailer_password: null
I try to set vars ORACLE_HOME and LD_LIBRARY_PATH inside /etc/sysconfig/httpd and httpd.conf files, but not works

-bash: mongo: command not found AWS

I have installed Mongodb server in AWS. Mongodb server is up and running. But, I'm unable to connect to mongo shell. Mongo shell is not being recognized. Normally all utilities are present in the same directory as mongod utility. But, I could not find mongo utility in /usr/bin/ directory.
I am unable to figure out the issue. Where am I going wrong?
$ ps -ef | grep mongo
mongod 21149 1 0 09:35 ? 00:00:01 /usr/bin/mongod -f /etc/mongod.conf
ec2-user 21226 21086 0 09:48 pts/0 00:00:00 grep mongo
$
$ mongo
-bash: mongo: command not found
$
MONGOD LOG
2014-05-18T09:35:18.239+0000 ***** SERVER RESTARTED *****
2014-05-18T09:35:18.262+0000 initandlisten MongoDB starting : pid=21149 port=27017 dbpath=/data/db 64-bit host=ip-172-31-1-234
2014-05-18T09:35:18.262+0000 initandlisten db version v2.6.1
2014-05-18T09:35:18.262+0000 initandlisten git version: 4b95b086d2374bdcfcdf2249272fb552c9c726e8
2014-05-18T09:35:18.262+0000 initandlisten build info: Linux build14.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-05-18T09:35:18.262+0000 initandlisten allocator: tcmalloc
2014-05-18T09:35:18.262+0000 initandlisten options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/data/db", journal: { enabled: false } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2014-05-18T09:35:18.332+0000 initandlisten waiting for connections on port 27017
2014-05-18T09:36:18.335+0000 clientcursormon mem (MB) res:45 virt:330
2014-05-18T09:36:18.335+0000 clientcursormon mapped:80
2014-05-18T09:36:18.335+0000 clientcursormon connections:0
Steps followed to install mongodb in AWS:
echo "[MongoDB]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1" | sudo tee -a /etc/yum.repos.d/mongodb.repo
sudo yum install -y mongo-10gen-server
you have to use
$ sudo yum install -y mongo-10gen-server mongodb-org-shell
and then
$ mongo
Mongo-10gen-server package doesnt include the component which is required to run "mongo" connecting to database running as mongod.
Use:
yum install mongodb-org
This will install all the required components.

Resources