Fix: PHP Startup: Unable to load dynamic library - createIT
Get a free advice now!

    Pick the topic
    Developer OutsourcingWeb developingApp developingDigital MarketingeCommerce systemseEntertainment systems

    Thank you for your message. It has been sent.

    Fix: PHP Startup: Unable to load dynamic library

    January 17, 2023
    Last update: August 29, 2024
    2 min read
    91
    0
    0
    Fix: PHP Startup: Unable to load dynamic library

    Challenge: WP CLI and PHP Composer is displaying PHP extension errors

    Solution: adjust php.ini settings for display_startup_errors

    The XAMPP server or localwp by freewheel are often used by developers to set up a PHP project locally. Running shell commands is often a necessity (WP CLI command line or PHP Composer). LocalWP offering “Open Site Shell” where commands can be executed.

    Depending on the selected PHP version (5.6.39, 7.3.5, 7.4.1 or 8.00), some PHP startup warnings can appear in the console. This can be frustrating because pipe linux commands use standard output and a warning can interfere with command execution.

    We have a site set up on localhost, our server is NGINX with PHP 7.4.1 enabled. Our environment is Windows with localWP application running in the background. How to fix PHP warnings when executing console commands? You will find a solution in this article.

    PHP warnings

    Missing PHP extensions or issues with loading them are common error messages. “The specified module could not be found” for php_imagick.dll is a popular one. You might see other warnings similar to those:

    Warning: PHP Startup: Unable to load dynamic library 'php_imagick.dll' (tried: C:/Program Files (x86)/Localwp/resources/extraResources/lightning-services/php-7.4.1+18/bin/win64/ext\php_imagick.dll (The specified module could not be found.), C:/Program Files (x86)/Localwp/resources/extraResources/lightning-services/php-7.4.1+18/bin/win64/ext\php_php_imagick.dll.dll (The specified module could not be found.)) in Unknown on line 0
    
    Warning: PHP Startup: Unable to load dynamic library 'php_pdo_mysql.dll' (tried: C:/Users/user1/AppData/Roaming/Local/lightning-services/php-8.0.0+3/bin/win64/ext\php_pdo_mysql.dll (The specified module could not be found.), C:/Users/user1/AppData/Roaming/Local/lightning-services/php-8.0.0+3/bin/win64/ext\php_php_pdo_mysql.dll.dll (The specified module could not be found.)) in Unknown on line 0
    
    Warning: PHP Startup: Unable to load dynamic library 'php_mysqli.dll' (tried: C:/Users/user1/AppData/Roaming/Local/lightning-services/php-7.3.5+11/bin/win64/ext\php_mysqli.dll (The specified procedure could not be found.), C:/Users/user1/AppData/Roaming/Local/lightning-services/php-7.3.5+11/bin/win64/ext\php_php_mysqli.dll.dll (The specified module could not be found.)) in Unknown on line 0

    PHP.ini location

    First, we need to determine where our PHP settings (php.ini) are stored. This command will return the location of the config file:

    $ php --ini

    Here is the output:

    Configuration File (php.ini) Path: C:\WINDOWS
    Loaded Configuration File:         C:\Users\user1\AppData\Roaming\Local\run\N4vHnB5kB\conf\php\php.ini
    Scan for additional .ini files in: (none)
    Additional .ini files parsed:      (none)

    PHP configuration

    Now, what is left is editing the php.ini file (in our situation, it is located on: C:\Users\user1\AppData\Roaming\Local\run\N4vHnB5kB\conf\php\php.ini ). Look for:

    display_startup_errors = On

    and change it to:

    display_startup_errors = Off
    Window with code

    Save the file. That’s it. Warnings will be not present anymore. Now you can execute WP CLI command without any problems. To test our solution, we will export WordPress tables started with the prefix:

    wp db export --tables=$(wp db tables 'wp_20*' --format=csv)

    Success! Here is the output:

    Success: Exported to 'local-2022-07-13-51e1a91.sql'.

    That’s it for today’s tutorial. Don’t forget to subscribe to our newsletter and stay up to date with other useful tips and guidelines.

    Do you need someone to implement this solution for you? Check out our specialists for hire in the outsourcing section. Are you considering a global project and are uncertain how to proceed? Maybe you don’t need an outsourced developers but a team to serve you while working on a custom web app development? Contact us!

    Meet our authors
    Aleksander Fredrych
    Alex
    Co-founder & CTO
    Monika Regulska
    Monika
    Head of Marketing
    Yuriy
    Yuriy
    Client's Ambassador
    Grzegorz Oleksa
    Grzegorz
    Content Specialist
    Maciej Brzeziński
    Maciej
    Technical Consultant

    Technology
    Be on the same page as the rest of the industry.

    Contact us