Problem with cURL and rest API

The curl_init function accepts an url and what you are passing there looks like a command line call.

Please check this link for an example of passing username and password through php curl functionality.

Basically you have to use just http://localhost/wp-json/wc/v1/products in curl_init and set username using curl_setopt function with CURLOPT_USERPWD parameter.

Example:

$ch = curl_init('http://localhost/wp-json/wc/v1/products');
curl_setopt($ch, CURLOPT_USERPWD,'your credentials');
//other options here
$res = curl_exec($ch);
curl_close($ch);