Tag Archives: Composer

Manual WAMP stack

For future reference…

PHP

  1. Download an x64 Thread Safe zip from php.net.
  2. Read the note about Visual C++ Redistributable in the sidebar of that download page, and install the one required for your version.
  3. Unzip somewhere and add to PATH.
  4. Pick a php.ini and adjust as necessary (enabled extensions, etc.).
  5. In particular, make sure the following is not commented out:
    extension_dir = "ext"
  6. Check that it works:
    php --version

Composer

  1. Download the Windows Installer from getcomposer.org.
  2. Run the installer..
  3. Check that it works:
    composer --version

Apache

  1. Download the Apache Win64 zip from apachelounge.com.
  2. Read the note about Visual C++ Redistributable above the downloads on that download page, and install the required one.
  3. Unzip somewhere and adjust httpd.conf as necessary (paths, enabled modules, etc.).
  4. Install as service:
    httpd.exe -k install
  5. Start the service.
  6. Check that it works:
    start http://localhost

Apache with PHP

  1. Add the following to httpd.conf.
    LoadModule php7_module C:/path/to/php/php7apache2_4.dll
    <IfModule php7_module>
        DirectoryIndex index.html index.php
        AddHandler application/x-httpd-php .php
        PHPIniDir "C:/path/to/php"
    </IfModule>
  2. Add an index.php to your DocumentRoot for testing, e.g.:
    <?php phpinfo();
  3. Restart the Apache service.
  4. Check that it works:
    start http://localhost

MariaDB

  1. Download a Windows x86_64 MSI Package via mariadb.org.
  2. Run the installer.
  3. Optionally add some of the following to my.ini under mysqld section:
    ; Only listen on localhost
    bind-address=127.0.0.1

    ; Enable logging of queries

    ; (probably bad in production, but very helpful for development debugging)
    general-log=1
    general-log-file=queries.log
    log-output=file
  4. Restart the service, if you changed anything in the ini.
  5. Check that it works by connecting with HeidiSQL or any other SQL client.

Edit composer dependencies “inline” while developing

Have a PHP project, and want to re-use some classes in a new project. Moving them to their own repository and turning them into a Composer dependency is a clean way to do that. If hosted on GitHub/BitBucket, it’s even simply to be a bit more proper and fancy by publishing the package on Packagist with automatic updates based on git tags. However, if still heavily developing both the project and the dependency, the round trip through repo/packagist is a pain.

But today I discovered there’s an option called --prefer-source which seems to solve most of this pain. And here’s a basic note-to-self on how to get that to work…

0. Make sure dependency is a composer dependency

// Dependency composer.json
{
    "name": "my/package",
    "autoload":
    {
        "psr-4": {"": "src/"}
    }
}

1. Add dependency repo and package to root project

// Root project composer.json
{
    "repositories":
    [
        {"type": "vcs", "url": "https://github.com/username/my-project"}
    ],
    "require":
    {
        "my/project": "dev-master",
    }

2. Run update with –prefer-source

$ composer require my/package dev-master --prefer-source

We should now have the package downloaded and, more importantly, if you check ./vendor/my/package it should have the .git directory, meaning you can make immediately working changes there directly, and commit when you’re happy… Our other root project(s) depending on it should then get the update from the source repository after an easy composer update. 👍


Note: I’m a bit fuzzy on what composer does to keep track on whatever different happens through --prefer-source, and it’s an option for both composer install and composer update. For example, at first attempt, I tried to use composer update --prefer-source on a dependency that had already been downloaded, and the .git directory did not turn up, but if I just deleted the vendor directory for that package and then re-ran the command, then the .git was there.

So, feel free to comment if you have some light on that topic 😛🤓