Simple wget Written in PHP
Sometimes you’re on a server with PHP but no wget. Maybe you don’t have permission to install packages. Maybe it’s a restricted shared hosting environment.
Here’s a simple PHP script that handles the basic operation: getting a file.
<?php
$url = $argv[1];
$filename = basename($url);
file_put_contents($filename, file_get_contents($url));
echo PHP_EOL . 'Written file ' . $filename . PHP_EOL;
Save it as wget.php and use it from the command line:
php wget.php https://example.com/file.zip
The script extracts the filename from the URL and saves the downloaded content to the current directory.
This isn’t a replacement for the real wget—no resume support, no recursive downloads, no authentication. It’s just the bare minimum for grabbing a file when you need it.
Sometimes that’s all you need.