添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Getting cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) error after saving models in laravel 5.4

Ask Question

I am having this error cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) after saving/creating multiple models to database.

I have this in my controller:

public function storeTruck(Request $request){
    //Save Company Detail
    $company = Company::Create($request->only(['company']));
    // Save Trucker Info
    $request->request->add(['password'=>bcrypt('trucker')]);
    $request->request->add(['company_id'=>$company->id]);
    $trucker = Trucker::create( $request->only([
        'first_name','last_name','company',
        'email','contact', 'password', 'company_id'
    return view('admin.truck.list'); 

Those models are saved successfully in database but it will then proceed to a cURL error 3 problem. What causes this error based on the codes? Please advice. Thanks.

  • Download download cacert.pem.
  • Save the file "cacert.pem" to your computer. For example C:\PHP\cacert.pem
  • Add the location of the "cacert.pem" file to your php.ini file.
    Search for [curl.cainfo] in your php.ini file and update the following line:
    curl.cainfo = "C:\PHP\cacert.pem"
  • Restart your web server.
  • php artisan config:cache
    php artisan cache:clear
    

    I made a mistake when instantiating the the Guzzle Client Object:

    Rather than assigning my baseUrl to th 'base_uri' key as below,

    $client = new Client([
            'base_uri' => $this->baseUrl
    

    I assigned the $baseUrl to the 'base_url' key, which does not exist.

    $client = new Client([
            'base_url' => $this->baseUrl
    

    Be careful when doing this. make sure you use 'base_uri' key instead of 'base_url'.

    Damn I've I been looking in all the wrong places. I hate loosing time on a simple Typo. Thanks, that fixed my issue. Just rephrasing a bit though. You say "base_uri" key both times. :) – Stéphan Champagne Feb 22, 2022 at 19:20

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.