I am learning how to use schema builder to create tables. I have got phpmyadmin running on 127.0.0.1:81/phpmyadmin. I created a db in phpmyadmin named testdb.
On my laravel app in app/config/database.php i have made changes to 'mysql' section as:
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1:81',
'database' => 'testdb',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
On app/routes.php i wrote :
Route::get('/', 'HomeController#showWelcome');
On app/controller/HomeController.php i wrote:
public function showWelcome()
{
Schema::create('employee', function($emp_table){
$emp_table->increments('id');
$emp_table->string('name');
$emp_table->integer('salary');
});
return View::make('hello');
}
Now i am getting a 'Something went wrong' message when reloading localhost:8000. It should be creating the table 'employee' with fields 'id', 'name' and 'salary'. The 'app/storage/logs/laravel.log' says:
[2015-01-14 06:09:49] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Maximum execution time of 60 seconds exceeded' in C:\wamp\www\stylop-dev\bootstrap\compiled.php:9301
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleShutdown()
#1 {main} [] []
Please help, i am stuck fixing this error and have hit a dead end :(
Well i guess i figured out why i was getting the error. I was using 127.0.0.1:81 so i changed it back to the default port 80.
Now it works
Related
I need a little help connecting an external MySQL database to Laravel Vapor. The database is located on a Hetzner Server and it seems like there is a failure using a tls encrypted connection:
==> Executing Function...
Status Code: 1
Output:
In Connection.php line 712:
SQLSTATE[HY000] [2002] (SQL: SELECT * FROM KURSE_planung )
In Exception.php line 18:
SQLSTATE[HY000] [2002]
In PDOConnection.php line 40:
SQLSTATE[HY000] [2002]
In PDOConnection.php line 40:
PDO::__construct(): SSL operation failed with code 1. OpenSSL Error message
s:
error:1416F086:SSL routines:tls_process_server_certificate:certificate veri
fy failed
I already tried to disable SSL by using the following params in the database URL without any luck:
MYSQL_DATABASE_URL=mysql://username:password#sql168.your-server.de/databasename?charset=utf8mb4&sslmode=disabled&ssl-mode=disabled&useSSL=false
Does anyone know how to disable TLS when connecting to the database or what else I can do about it?
Edit:
I managed to connect to the database. My Hoster Hetzner provides a certificate which needs to be provided to the connection configuration in database.php:
'mysql' => [
'driver' => 'mysql',
'url' => env('MYSQL_DATABASE_URL'),
'host' => env('MYSQL_DB_HOST', '127.0.0.1'),
'port' => env('MYSQL_DB_PORT', '3306'),
'database' => env('MYSQL_DB_DATABASE', 'forge'),
'username' => env('MYSQL_DB_USERNAME', 'forge'),
'password' => env('MYSQL_DB_PASSWORD', ''),
'unix_socket' => env('MYSQL_DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => base_path(env('MYSQL_ATTR_SSL_CA')),
]) : [],
],
Then in the .env file one needs to set the correct path to the certificate using MYSQL_ATTR_SSL_CA.
One question remains: does anyone know how to disable SSL for MySQL on Vapor?
Best regards
Clemens
I don't know if this might help. But In my case Laravel Vapor was hosted with RedHatOS, then I defined the env with the following:
MYSQL_ATTR_SSL_CA=/etc/pki/tls/certs/ca-bundle.crt
In my case, the database is hosted on planetscale this configration a specified on the documentation
This question already has answers here:
Laravel 5 PDOException Could Not Find Driver [duplicate]
(11 answers)
Closed 2 years ago.
I'm trying to set up a development environment after not having done web dev in over a year. I've installed php 7.2.7 on my computer, then installed composer and WAMP.
I'm using php artisan serve to set up a local server. I'm trying to create a new user in my database's 'users' table, using the following code in my web.php (routes) file.
Route::get('/new', function(){
User::create([
'password' => Hash::make('anything'),
'firstname' => 'Nick',
'lastname' => 'xyz',
'email' => 'xyz#ph.com',
'roleflag' => 0
]);
});
But am getting the following error:
This seems to be a pretty common error, and I have found help on other stackoverflow/laracasts posts such as:
Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL
and
https://laracasts.com/discuss/channels/general-discussion/cant-connect-to-sql-server-could-not-find-driver
I've thus uncommented the two lines from my php.ini file, changed my .env and config/database.php file to have appropriate settings/connection values, etc. but still receive this error.
Relevant config.php code:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('venturebreeder', 'forge'),
'username' => env('root', 'forge'),
'password' => env('', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
I'm a bit slower at troubleshooting since it has been a while since I've done this -- can anyone see what I'm doing wrong? Help much appreciated.
What lines did you uncomment in php.ini file?
Do you have the pdo_mysql extension installed?
Remove the ; from ;extension=pdo_mysql.so and restart your WAMP server
Source: https://stackoverflow.com/a/35240511/6385459
Getting this error message RANDOMLY while nav'ing to my view:
QueryException in Connection.php line 636:SQLSTATE[42S02]: Base table or view not found: 1146 Table 'salesspacetv.devices' doesn't exist (SQL: select count(*) as aggregate from devices inner join statustypes on devices.status = statustypes.num inner join aggservers on devices.aggserver_num = aggservers.num left join tickets on devices.id = tickets.device_id group by devices.id) in Connection.php line 636
My server uses multiple virtual hosts, defined in c:\apache24\conf\extra\httpd-vhosts.conf.
"c1.[ourcompanyname].net" is the name of the site whose view I'm nav'ing to.
"salesspacetv.[ourcompanyname].net" is another virtual host (running laravel) on our server.
The word "salesspacetv" absolutely does not exist anywhere in c1's code.
"devices" IS a table used by the c1 site, and there is no "devices" table used by the salesspacetv site.
It seems like laravel's base code is making use somewhere of what it thinks is the subdomain name and that Apache (fyi... running on Windows, on this server) is somehow not getting the correct subdomain name to laravel.
Again, this is a random error. If I simply refresh the page, the error goes away. Also note, whether important or not, that this view is using pagination. I don't imagine that has any importance, but I figured it was worth mentioning.
The databases are MySQL databases.
Lastly, the c1 virtual host definition does actually appear before the salesspacetv virtual host definition in httpd-vhosts.conf.
Thanks.
I believe I ran into this error in the past when I was dealing with multiple projects in my local environment.
Let me get this straight, you are using 1 project then whenever it is involving a database table call it sometimes references to a table or column name that the current project does not contain but contains in another project?
If that is what's happening to you, how I fixed it on my end was name your database environments (.env file) different per project.
#1 .env Method
.env
Project 1:
DB_PROJECT1_HOST=0.0.0.0
DB_PROJECT1_DATABASE=dbname
DB_PROJECT1_USERNAME=dbuser
DB_PROJECT1_PASSWORD=dbpass
Project 2:
DB_PROJECT2_HOST=0.0.0.0
DB_PROJECT2_DATABASE=dbname
DB_PROJECT2_USERNAME=dbuser
DB_PROJECT2_PASSWORD=dbpass
app\config\database.php
Project 1:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_PROJECT1_HOST'),
'database' => env('DB_PROJECT1_DATABASE'),
'username' => env('DB_PROJECT1_USERNAME'),
'password' => env('DB_PROJECT1_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
Project 2:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_PROJECT2_HOST'),
'database' => env('DB_PROJECT2_DATABASE'),
'username' => env('DB_PROJECT2_USERNAME'),
'password' => env('DB_PROJECT2_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
Hopefully this is the same issue happening to you so you can quickly test this and see if it applies to you.
#2 Alternative (hardcode method suggested by Tezla):
You may also edit the database configuration file (app\config\database.php) and hardcode the database information directly to avoid configuration leaks:
'mysql' => [
'driver' => 'mysql',
'host' => '0.0.0.0',
'database' => 'dbname',
'username' => 'dbuser',
'password' => 'dbpass',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
]
When I try to login to the app I have setup on Forge, my Laravel app spits out this error:
SQLSTATE[HY000] [1045] Access denied for user 'appname'#'localhost' (using password: YES)
I have the environment variables configured correctly and they work fine on my copy of the site on my local Homestead vagrant box.
Here is the .env.php file that Forge wrote:
return [
'APP_ENV' => 'production',
'DB_DRIVER' => 'mysql',
'DB_HOST' => 'localhost',
'DB_NAME' => 'appname',
'DB_USER' => 'appname',
'DB_PASS' => 'LoNgPaSsWoRd',
];
Here is the relevant contents of app/config/database.php which works locally:
'default' => getenv('DB_DRIVER'),
'connections' => array(
'mysql' => array(
'driver' => getenv('DB_DRIVER'),
'host' => getenv('DB_HOST'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USER'),
'password' => getenv('DB_PASS'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
),
I tried dumping the environment values before the first database connection is accessed using dd(getenv('DB_PASS'), getenv('DB_USER')) and they show up correct.
I also tried connecting through MySQL Workbench and resetting the password to exactly what is shown in the environment variable Forge wrote.
None of my other subdomains are having this issue.
What could be going on here and how could I debug this?
I deployed my app on a remote host and everything works as expected. But when I try to test my code on localhost, it gives me the following error, without any change to the code working on the host:
Fatal error: Class 'AppHelper' not found in [path]
I am using CakePHP 2.1 and MySQL as my default datasource.
I connect to my local database just like to the remote one (with authentication changes):
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'database',
'prefix' => '',
'encoding' => 'utf8',
);
Why isn't this working on my localhost? Thank you
Two possible things:
either you didnt know about the AppHelper requirement for 2.1:
http://book.cakephp.org/2.0/en/appendices/2-1-migration-guide.html
or you forget to declare the helper at the very top of your class:
App::uses('AppHelper', 'View/Helper');
Although the second one is highly unlikely if you are not running any unit tests.
So my bet is on the first one.