Get a free advice now!

    Pick the topic

    [checkbox* "Developer Outsourcing" "Web developing" "App developing" "Digital Marketing" "eCommerce systems" "eEntertainment systems"]

    Thank you for your message. It has been sent.

    Tags

    Fix: PHP Startup: Unable to load dynamic library

    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.

    Comments
    0 response

    Add comment

    Your email address will not be published. Required fields are marked *

    Popular news

    PHPStorm – fix long load time of a directory window
    • Dev Tips and Tricks

    PHPStorm – fix long load time of a directory window

    January 20, 2023 by createIT
    reCAPTCHA v3 – WordPress implementation
    • Dev Tips and Tricks

    reCAPTCHA v3 – WordPress implementation

    January 20, 2023 by createIT
    How to compare GIT and server files
    • Dev Tips and Tricks

    How to compare GIT and server files

    January 19, 2023 by createIT
    How to trigger a click event inside iframe?
    • Dev Tips and Tricks

    How to trigger a click event inside iframe?

    January 19, 2023 by createIT
    FOOEvents – generate a custom CSV report
    • Dev Tips and Tricks

    FOOEvents – generate a custom CSV report

    January 19, 2023 by createIT
    Headless chrome – testing webgl using playwright
    • Dev Tips and Tricks

    Headless chrome – testing webgl using playwright

    January 18, 2023 by createIT
    Preview big SQL files with PilotEdit
    • Dev Tips and Tricks

    Preview big SQL files with PilotEdit

    January 18, 2023 by createIT
    Outsourcing a team of backend developers
    • Our Highlights

    Outsourcing a team of backend developers

    January 18, 2023 by createIT
    A new look for an aspiring brand
    • Our Highlights

    A new look for an aspiring brand

    January 18, 2023 by createIT
    Percy AI visual regressions – playwright example
    • Dev Tips and Tricks

    Percy AI visual regressions – playwright example

    January 17, 2023 by createIT

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

    Contact us