@zaidk26 Depends on the actions you are performing with any of those three things.
Are all three of them, three separate laravel installs? If so, which versions?
Let's see the error first, and then info on what is site C actually performing and how.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi guys, I have picked up the following issue. On my local dev machine, i'm running ampps.
site a - sss.dev , normal page no db connections
site b - recipes.dev queries recipe table on localhost port 3306
site c sync.dev connects to a remote db on port 3306 , lets call it 1.sql.com
these sites work perfect on their own, site c , script runs for a long time as it uploads a fair amount of data to the remote db.
while site c script is running , if i try and access site a , it gives error memcached not found, as soon as the script stops, site starts working again. and on site b , if i try and access site while script on site c is running , it fails in querying the recipes table because instead of looking at localhost.recipes , it tries to find it at recipes.1.sql.com .
Both db's are on the same port , so i taught that was causing the issue. So i tried running the script on site c , and accessed a non laravel site , that uses the localhost db and it works fine . so it seems , the problem has to do to with laravel .
Any help , ideas's suggestion to try out as i'm lost
@zaidk26 Depends on the actions you are performing with any of those three things.
Are all three of them, three separate laravel installs? If so, which versions?
Let's see the error first, and then info on what is site C actually performing and how.
Heres a gist of the script thats running on site c. It opens a odbc connections, get data from a local file and updates the remote db . By the way site c is lumen and others are laravel. The remote db connection properties are in the .env file.
namespace App\Http\Controllers; class SyncController extends Controller {protected function connect(){
$user = '';
$pass = 'PASSWORD';
$path = env('DATA_PATH');
$connection_string = "Driver={SoftVelocity Topspeed driver (*.tps)};Dbq={$path}";
return $con = odbc_connect($connection_string,$user,$pass);
}
public function syncJobs()
{
$this->jobControlSync();
}
public function jobControlSync()
{
$con = $this->connect();
if ($con) {
$sql = "SELECT JOB_NO,CUSTOMER_CODE,MODEL_NO,IMEI_IN,LOCATION,STATUS FROM Job_Control";
$exc = odbc_exec($con, $sql);
if ($exc) {
$rc = 0;
$content = '';
while ($row = odbc_fetch_array($exc)) {
$content .= '(\'' . addslashes($row['JOB_NO']) . '\',
\'' . addslashes($row['CUSTOMER_CODE']) . '\',
\'' . addslashes($row['MODEL_NO']) . '\',
\'' . addslashes($row['IMEI_IN']) . '\',
\'' . $row['LOCATION'] . '\',
\'' . $row['STATUS'] . '\'),';
if (($rc % 1000) == 0) {
$this->addToJobControlTemp(rtrim($content, ","));
$content = '';
}
$rc++;
}
if ((strlen($content)) > 2) {
$this->addToJobControlTemp(rtrim($content, ","));
}
}
}
odbc_close($con);
//Move from temp to live db
$this->processJobControl();
}
/**
* @param $values
*/
protected function addToJobControlTemp($values){
app('db')->insert("INSERT INTO job_control_temp ( job_number,
customer_code,
model_number,
imei_in,
job_location,
job_status)
VALUES $values");
}
/**
*Move from temp to live
*/
protected function processJobControl()
{
app('db')->transaction(function () {
app('db')->statement("INSERT INTO job_control( job_number,
customer_code,
model_number,
imei_in,
job_location,
job_status)
SELECT job_number,
customer_code,
model_number,
imei_in,
job_location,
job_status
FROM job_control_temp
ON DUPLICATE KEY UPDATE
job_location=VALUES(job_location), job_status=VALUES(job_status)");
app('db')->table("job_control_temp")->truncate();
});
}
}
@zaidk26 Understood. Are you using memcached anywhere at all?
also can i see the log of the error from laravel.log?
@zaidk26 I added your number. I will ping you tomorrow morning as now i'm travelling.
Writing from my ipad. Delete your last post though :p
ps. Regardless post the error from the laravel.log reagrding memcache. Still need to look at that.
Ive done more tinkering, And from what I can gather is , when the site c is running its script which take slong to run , the other laravel sites , use the .env settings from site c , instead of their own . They are all in separate folders obviously .
They couldn't.
I have 20-something project running in one of the servers. Never has it happened that they mix .env files.
Here is the log :
[2015-09-13 20:24:35] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Memcached' not found' in C:\APPS-WEB\sss\vendor\laravel\framework\src\Illuminate\Cache\MemcachedConnector.php:51 Stack trace: #0 {main}
@zaidk26 check under all three of those apps, under .env or config/cache.php, does any of them have Memcache as a cache driver?
Done more testing, In site c .env file it had memcached as the driver. while site c script is running then site a , give the memcached not found error.
so i changed , site c driver to file, and site a display's a different error, basically trying to look for a table in site c 's database , instead of its own . hence i say , only when the script is running, it's using the wrong .env file . Non laravel sites are working fine .
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ssscewjtxr_db1.recipes' doesn't exist (SQL: select recipes., users., COUNT(DISTINCT ratings.RecipeID) as trates from recipes left join users on recipes.User = users.Email left join ratings on ratings.RecipeID = recipes.RecipeID where recipes.ImageBig != /frontend/static/images/rec_default.jpg and recipes.ImageBig != /recipes/pictures/default.jpg group by recipes.RecipeID order by recipes.RecipeID desc limit 6)
Error above is from site a error, Thats db in the above error is site c db .
@zaidk26 This is hella obscure.
I mean, look, if you're not placing this code publicly on Github or smth, if this is the case, take the settings for each one of those apps, and place it in the relevant file as opposed to the .env file.
APP_ENV=local
APP_DEBUG=true -> 'debug' on config/app.php
APP_KEY=my_key -> 'key' on config/app.php
//all these on config/database.php
DB_HOST=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
// config/cache.php
CACHE_DRIVER=file
config/session.php
SESSION_DRIVER=file
config/queue.php
QUEUE_DRIVER=sync
config/mail.php
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Then rename .env to .env_backup or whatever so Laravel leaves it alone, and your apps will work just fine.
This way all your apps can go back to working normal.
After that maybe file an Issue on Laravel at Github.
What do you think?
@sid405 Thanks for the above suggestion, doing that and everything works as expected.
I picked up that if you do phpinfo(). under the php variables sections , it picks up your .env file settings , e.g below . Is this expected behavior ?
_ENV["APP_ENV"] local
_ENV["APP_DEBUG"] true
_ENV["APP_KEY"] 23sdkhwkck2k4l90dplsmndf4r4ekljn
_ENV["APP_LOCALE"] en
_ENV["APP_FALLBACK_LOCALE"] en
_ENV["DATA_PATH"] C:\APPS-WEB\SSSCL
_ENV["DB_CONNECTION"] mysql
_ENV["DB_HOST"] xxx.xxx.host-h.net
_ENV["DB_DATABASE"] ssscewjtxr_xxx
_ENV["DB_USERNAME"] xxx
_ENV["DB_PASSWORD"] xxx
_ENV["DB_PORT"] 3306
_ENV["CACHE_DRIVER"] file
_ENV["SESSION_DRIVER"] file
_ENV["QUEUE_DRIVER"] database
@zaidk26 Glad you solved it.
Was thinking about this this morning . Fact is what complicates the matter here is the setup itself- I'll explain myself-
The .env file with the variables was created so that people would not push their credentials to github repositories and other places where they may share the source.
Now, being environment variables they become system wide for the entire duration of the http request (in this case script execution). The point is that you got a long running script.
To find a definitive solution you could go one of the three ways.
OR
In the long run i would be perhaps for this last one. What i mean is in the .env of site_c
APP_ENV_C =
APP_DEBUG_C =
...
In the .env of site_b
APP_ENV_B =
APP_DEBUG_B =
...
And reference properly in the required files.
This would be the ultimate solution. What do you think?
ps. Don't forget to vote :p
Dear @sid405, thank you for your great contribution. Once it was 5 years ago, I'm wondering: "Is there any update how to solve this issue?" I'm running a test environment together with production environment. Both are running in the same IIS server where I have MySQL with two separated DB. I'm facing weird connection problems with DB.
@sid405 Thanks for the help buddy !
@sid405 thanks, you save my day! What a ultimate solution it is!
Please or to participate in this conversation.