0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ubuntu24にてcomposerインストールしてmPDFをそのPHPプロジェクト直下にセットアップ

Posted at

以下の手順Composerのインストール。

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php composer-setup.php

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

php -r "unlink('composer-setup.php');"

composer

   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.8.12 2025-09-19 13:41:59

Usage:
  command [options] [arguments]

Options:
  -h, --help                     Display help for the given command. When no command is given display help for the list command
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi|--no-ansi           Force (or disable --no-ansi) ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
      --no-scripts               Skips the execution of all scripts defined in composer.json file.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
      --no-cache                 Prevent use of the cache
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
....................

インストールできれば上記メッセージ表示。
mpdfをPHPプロジェクトの直下にインストール。
phpのバージョンの各PHPの依存関係管理ツール、確認とインストール。

apt install php7.3-cli php7.3-curl php7.3-mbstring php7.3-xml composer

composer require mpdf/mpdf
直下の./vendorをapacheに合わせ、www-dataに変更。
drwxr-xr-x  8 www-data www-data   4096 Sep 21 13:05 vendor

テストスクリプト
<?php
       require_once __DIR__ . '/vendor/autoload.php'; 

       $mpdf = new \Mpdf\Mpdf();
       $mpdf->WriteHTML('Hello World');
       $mpdf->Output();
 ?>

下記PDF出力。

参考サイト:
https://kinsta.com/jp/blog/install-composer/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?