TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸

Using a third-party library with PHP

February 24, 2015

Empfehlung: Composer

Composer ist der Standard fuer PHP Dependencies.

Install

code
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer -V

Projekt starten

code
composer init
composer require phpmailer/phpmailer

In PHP:

code
require __DIR__ . "/vendor/autoload.php";

Ohne Composer (legacy)

Wenn du Libraries manuell einbindest, nutze require_once:

code
require_once "path/to/class.phpmailer.php";

Unterschied:

  • include wirft nur Warning
  • require stoppt bei Fehler
  • *_once laedt nur einmal