Skip to content

Commit e4c6784

Browse files
committed
remove feature: directory-based auto include
1 parent 6bae3a1 commit e4c6784

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

README.md

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ via composer. include this snippet to composer.json
3030

3131
Assume we have our php application in `/var/www/myApp`. A `/var/www/myApp` is our application root directory (`./`).
3232

33-
example: `./index.php`
33+
example: file `./index.php`
3434
```php
3535
<?php
3636
//require piLoader
@@ -54,7 +54,7 @@ PI::joinPath("/var/www", "dist/app.zip"); //returns "/var/www/dist/app.zip", pre
5454
PI::joinPath("C:\\www\\", "/dist/app.zip"); //returns "C:\\www/dist/app.zip", mixed result for Windows path (still works in PHP)
5555
PI::joinPath("C:\\www", "dist/app.zip"); //returns the same...
5656
```
57-
**example**: `./login/index.php`
57+
**example**: file `./login/index.php`
5858
```php
5959
<?php
6060
//require piLoader
@@ -79,34 +79,16 @@ If there is a `pi.global.php` file in the application root directory, it is auto
7979
```php
8080
<?php
8181

82-
//class auto loader
82+
//here you can already use a php-includer object, it is already included
83+
include $pi->path("conf/config.php"); //includes /var/www/myapp/conf/config.php
84+
85+
86+
//This file is a right place to write the class auto loader
8387
$autoLoaderFile = __DIR__ . "/vendor/autoload.php";
8488
if (file_exists($autoLoaderFile)) {
8589
require_once $autoLoaderFile;
8690
}
8791

88-
//here you can already use a php-includer object, it is already included
89-
include $pi->path("conf/config.php"); //includes /var/www/myapp/conf/config.php
9092
```
9193

9294
From the previous examples, `./pi.global.php` will be included in both `./index.php and` `./login/index.php` files.
93-
94-
### Auto include, based on a directory
95-
96-
If there is a `pi.dir.php` file in a `directory`, it is automatically included, wherever you include/require `piLoader` in php files in that `directory`.
97-
98-
**example**: `./user/pi.dir.php`
99-
```php
100-
<?php
101-
//here you can already use a php-includer object, it is already included
102-
include $pi->path("conf/config.php");
103-
104-
//restrict the access
105-
if (userIsNotLoggedIn) {
106-
require $pi->path("login/index.php"); //requires "/var/www/myApp/login/index.php"
107-
}
108-
```
109-
110-
`./user/pi.dir.php` will be applied to all files in (and only) the `./user` directory that includes the `piLoader`.
111-
112-
**note**: `pi.dir.php` inclusion behavior does not act recursively - that is, no eventual `pi.dir.php` from parent directory is included

piLoader.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,3 @@
1313
include_once $fileToIncludeAlways;
1414
}
1515

16-
//within the directory of a top-level includer
17-
$fileToIncludeOnDirectoryLevel = "pi.dir.php";
18-
if (file_exists($fileToIncludeOnDirectoryLevel)) {
19-
include_once $fileToIncludeOnDirectoryLevel;
20-
}

0 commit comments

Comments
 (0)