Category: Web development

  • Set up Drupal on Laravel Valet

    1. Create a directory for the site & install Drupal files

      All my sites live in ~/sites, so I navigated there in macOS Terminal and ran these commands. I want my Drupal site in a folder named p8hd and my local website to live at https://p8hd.test.

      composer create-project drupal/recommended-project:10.4.1 p8hdcd p8hd
      valet link
      valet secure
      

      This creates a directory at “~/sites/p8hd”, populates it with composer.json and composer.lock files, installs the composer dependencies, creates a symbolic link, and creates a TLS certificate. A website is now live at the URL https://p8hd.test.

      I chose 10.4.1 because I am running PHP 8.2.26 and that’s the latest compatible version of Drupal.

    2. Create a database

      I copied these commands from the Drupal installation guide.

      mysql -u root -p -e "CREATE DATABASE p8hd CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
      mysql -u root -p

      Enter the database password twice, and paste this query at the mysql prompt:

      GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON p8hd.* TO 'root'@'localhost';
    3. Visit the site and run the installer

      https://p8hd.test redirects to https://p8hd.test/core/install.php and that’s a good thing.

    Screenshot

    Here is a screenshot of https://p8hd.test after running the installer:

    p8h Welcome! You haven't created any frontpage content yet. Congratulations and welcome to the Drupal community.
  • Laravel Valet PHP.ini Path

    The path to the php.ini file my Laravel Valet uses is /opt/homebrew/etc/php/8.1/php.ini

    In order to see changes in phpInfo() calls, the valet restart command is not good enough. I must use the command brew services restart [email protected]