Package: php-nesbot-carbon
Version: 1.27.0-2
Severity: wishlist
Tags: patch

Dear Maintainer,

Please consider including an autoloader (autoload.php) in the package.

Many PHP library packages contain a file (autoload.php) defining an
autoloader for the library's classes and loading its own dependencies.
It's then sufficient for the client to include this one file to use the
library, without care for the its internals, dependencies, etc.

Outside of Debian packaging, this is often similarly handled with Composer's
"vendor/autoload.php" file.

I've attached a patch to implement this, should you be interested.

Regards,
Robin


-- System Information:
Debian Release: 10.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-6-amd64 (SMP w/12 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages php-nesbot-carbon depends on:
ii  php-common               2:69
pn  php-symfony-translation  <none>

php-nesbot-carbon recommends no packages.

php-nesbot-carbon suggests no packages.
>From c68adc94881cf69613c15531b873ff9778f1e901 Mon Sep 17 00:00:00 2001
From: Robin Gustafsson <ro...@rgson.se>
Date: Thu, 2 Jan 2020 20:34:10 +0100
Subject: [PATCH] Add an autoloader

---
 debian/autoload.php.tpl | 24 ++++++++++++++++++++++++
 debian/clean            |  1 +
 debian/control          |  2 +-
 debian/rules            |  4 ++++
 4 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 debian/autoload.php.tpl
 create mode 100644 debian/clean

diff --git a/debian/autoload.php.tpl b/debian/autoload.php.tpl
new file mode 100644
index 0000000..89c4f4f
--- /dev/null
+++ b/debian/autoload.php.tpl
@@ -0,0 +1,24 @@
+<?php
+
+require_once 'Symfony/Component/Translation/autoload.php';
+
+// @codingStandardsIgnoreFile
+// @codeCoverageIgnoreStart
+// this is an autogenerated file - do not edit
+spl_autoload_register(
+    function($class) {
+        static $classes = null;
+        if ($classes === null) {
+            $classes = array(
+                ___CLASSLIST___
+            );
+        }
+        $cn = strtolower($class);
+        if (isset($classes[$cn]) and file_exists(___BASEDIR___$classes[$cn])) {
+            require ___BASEDIR___$classes[$cn];
+        }
+    },
+    true,
+    false
+);
+// @codeCoverageIgnoreEnd
diff --git a/debian/clean b/debian/clean
new file mode 100644
index 0000000..d8d15f2
--- /dev/null
+++ b/debian/clean
@@ -0,0 +1 @@
+src/Carbon/autoload.php
diff --git a/debian/control b/debian/control
index 71e1ff0..cda966f 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: php
 Priority: optional
 Maintainer: Teckids Debian Task Force <t...@lists.teckids.org>
 Uploaders: Thorsten Glaser <t...@mirbsd.de>, Dominik George 
<naturesha...@debian.org>
-Build-Depends: debhelper-compat (= 12), pkg-php-tools (>= 1.7~)
+Build-Depends: debhelper-compat (= 12), pkg-php-tools (>= 1.7~), phpab
 Standards-Version: 4.4.1
 Homepage: https://carbon.nesbot.com/
 Rules-Requires-Root: no
diff --git a/debian/rules b/debian/rules
index 3b60be1..4a6c6bd 100755
--- a/debian/rules
+++ b/debian/rules
@@ -2,3 +2,7 @@
 
 %:
        dh $@ --with phpcomposer
+
+override_dh_auto_build:
+       dh_auto_build
+       phpab -o src/Carbon/autoload.php -t debian/autoload.php.tpl src/Carbon
-- 
2.20.1

Reply via email to