Created a basic php file with a so simple code below on an empty folder in my sites folder
<?php
exec('touch ' . rand(1,100));
?>
when I visit the folder from browser like foldername.test, this php code generates two different file in working directory. I also test it with a simple PDO code that inserts only one row into table however it inserts two rows.
Hey XEngine, I've got the same problem, did you figure out what the cause was?
Hello @indexsmithy, Currently I found no solution but I am now using Valet plus instead of valet, however didn't test this bug on that. https://github.com/weprovide/valet-plus
I run into the same issue. I created a simple project:
{ "require": {
"illuminate/database": "^5.7" }
}
i put my index.php in the root, and ran valet link, loaded up php file in valet url.
The php was processed twice, as i got 2 inserts.
Subsequently running same code on built in php server it ran only once.
I created a public folder, moved the index.php to it, valet unlinked the root folder.
Ran valet link inside the public folder. browsed to it. no more duplicate inserts!
Addendum: I valet unlinked the public folder, deleted public, moved index.php back to root.
Then created a LocalValetDriver.php which extended LaravelValetDriver, and added this:
public function frontControllerPath($sitePath, $siteName, $uri)
{
return $sitePath.'/index.php';
}
Valet link again in the root, this time it worked, only 1 insert.
Hej,
nope - this isn't a bug in valet. there is a simple way to reproduce it.
step 1: create an index.php file with the following content:
<?php
exec('touch ' . rand(1,100));
now your directory should look like this
~/Code/test 禄 ls -la
total 8
drwxr-xr-x 3 jw staff 96 Dec 22 21:46 .
drwxr-xr-x 19 jw staff 608 Dec 22 21:30 ..
-rw-r--r-- 1 jw staff 39 Dec 22 21:30 index.php
step 2: create a domain and optional create an ssl cert
valet link --secure
step 3: open the path in browser with the command valet open
step 4: list code directory. there sould be a random file now
~/Code/test 禄 ls -la
total 8
drwxr-xr-x 4 jw staff 128 Dec 22 21:47 .
drwxr-xr-x 19 jw staff 608 Dec 22 21:30 ..
-rw-r--r-- 1 jw staff 0 Dec 22 21:47 51
-rw-r--r-- 1 jw staff 39 Dec 22 21:30 index.php
step 5: delete the new file
step 6: open safari browser and insert the URL to your test environment, but do not press enter.
step 7: list directory again
~/Code/test 禄 ls -ltrah
total 8
drwxr-xr-x 19 jw staff 608B Dec 22 21:30 ..
-rw-r--r-- 1 jw staff 39B Dec 22 21:30 index.php
-rw-r--r-- 1 jw staff 0B Dec 22 21:51 22
drwxr-xr-x 4 jw staff 128B Dec 22 21:51 .
step 8: press enter, there should be another random file.
I my opinion there is a preloading of websites in modern browsers. That is the reason for two random files, which is mentioned by @XEngine in the first post.
there is no error in valet.
cheers
Yes, this is my understanding of the situation as well.
@mattstauffer I think this can be closed.
Great sleuthing!
Most helpful comment
Hej,
nope - this isn't a bug in valet. there is a simple way to reproduce it.
step 1: create an index.php file with the following content:
now your directory should look like this
step 2: create a domain and optional create an ssl cert
valet link --securestep 3: open the path in browser with the command
valet openstep 4: list code directory. there sould be a random file now
step 5: delete the new file
step 6: open safari browser and insert the URL to your test environment, but do not press enter.
step 7: list directory again
step 8: press enter, there should be another random file.
I my opinion there is a preloading of websites in modern browsers. That is the reason for two random files, which is mentioned by @XEngine in the first post.
there is no error in valet.
cheers