Map-based autoloader across php and phar resources

⌈⌋ branch:  Canonic Autoloader


Check-in [806985bee2]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Transition to xpm package+phar building. Fix self::$instance[] appending.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:806985bee25159b1c3e016b6176d09069c3bf659
User & Date: mario 2015-01-22 20:15:56
Context
2015-01-22
20:16
Test build of 0.3.4 check-in: 2c46bdbe2d user: mario tags: trunk
20:15
Transition to xpm package+phar building. Fix self::$instance[] appending. check-in: 806985bee2 user: mario tags: trunk
19:43
Update notes about pharmap.php and addPhar(). (Section about recommended alternative autoloaders finally committed.) check-in: 9a42dc06af user: mario tags: trunk
Changes

Changes to mk.

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh


#-- bump version
VERSION=$(version  read stub.php  bump show  write::2 stub.php)

#-- update shared.phar package
phar stub-set   -f shared.phar -s stub.php 
phar add -c gz  -f shared.phar autoload.update.php
#phar add -c gz -f shared.phar autoload.map.php
php ./single/shared.phar

#-- build release files
version $VERSION \
	write shared.phar	\
	write composer.json	\
	write php-shared-autoloader/DEBIAN/control
fakeroot dpkg-deb -b php-shared-autoloader/ php-shared-autoloader_$VERSION.deb
dpkg-sig -s builder -k include-once -v php-shared-autoloader_$VERSION.deb

>




|
|
|
|
|
|
|
|
|
|
|
<
<
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17


#!/bin/sh


#-- bump version
VERSION=$(version  read stub.php  bump show  write::2 stub.php)

#-- create plain phar
xpm -s src -t phar --phar-format zip-gz --phar-stub stub.php -f stub.php

# compact
chmod +x shared.phar
ln -f shared.phar single/
php single/shared.phar


#-- deb + rpm
xpm -s dir -t deb,rpm -n php-shared-autoloader -v $VERSION shared.phar=/usr/share/php/shared.phar


Changes to stub.php.

1
2

3
4
5
6
7
8
9




10
11
12
13
14
15
16
...
164
165
166
167
168
169
170
171
172

173
174
175
176
177
178
179
<?php
/**

 * api: php
 * title: Canonic Autoloader / shared.phar
 * description: Map-based autoloader across .php and .phar resources.
 * version: 0.3.4
 * depends: php:phar | php >= 5.3
 * category: cli
 * license: Public Domain




 *
 *
 * Self-contained autoloader which provides .php and .phar class
 * loading based on a map.
 *
 * Usable for per-project classpath and /usr/share/php handling.
 * It's indifferent to PSR-0/PSR-4 or custom directory schemes.
................................................................................

        /**
         * Create instance and register it.
         *
         */
        public static function hookup($basefn) {
            spl_autoload_register(
                self::instances[] = new Canonic_Autoloader( include(self::pharBase($basefn) . self::MAP_FILE), $basefn )
            );

        }
        
        // keep a reference
        static $instances = array();

     
        /**


>



|



>
>
>
>







 







|

>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
/**
 * id: shared
 * api: php
 * title: Canonic Autoloader / shared.phar
 * description: Map-based autoloader across .php and .phar resources.
 * version: 0.3.4-9
 * depends: php:phar | php >= 5.3
 * category: cli
 * license: Public Domain
 * url: https://fossil.include-once.org/canonic_autoloader/
 * architecture: all
 * main: .phar/stub.php
 * pack: stub.php=, autoload.update.php, autoload.map.php
 *
 *
 * Self-contained autoloader which provides .php and .phar class
 * loading based on a map.
 *
 * Usable for per-project classpath and /usr/share/php handling.
 * It's indifferent to PSR-0/PSR-4 or custom directory schemes.
................................................................................

        /**
         * Create instance and register it.
         *
         */
        public static function hookup($basefn) {
            spl_autoload_register(
                $i = new Canonic_Autoloader( include(self::pharBase($basefn) . self::MAP_FILE), $basefn )
            );
            self::$instances[] = $i;
        }
        
        // keep a reference
        static $instances = array();

     
        /**