@@ -38,6 +38,71 @@ P.S. The framework I develop for my own projects, but I'm really happy to share
3838anyone who is interested in it. Feel free to participate! Suggestions, bug-reports.
3939I will be really happy hearing from you.
4040
41+ ----
42+
43+ ## Changelog
44+
45+ ### 1.1.0
46+
47+ * Implemented ` FS::require() ` , ` FS::include() ` and ` FS::data() `
48+ * Implemented ` PHP::listOfExecPhpFileExtensions() ` , ` PHP::listOfExecPhpMimeTypes() `
49+ * Now array/box argument for ` File ` constructor is allowed (like for ` FS::locate() ` )
50+ * Added support of ` FS::locate() ` alike array/box of path components for ` fl() ` ,
51+ ` FS::file() ` and ` File ` . So now ` fl(['part1', 'part2', 'file.txt']) ` will make a file
52+ object with path: "{working-dir}/part1/part2/file.txt"
53+ * In ` BasicInitConfig ` introduced component-aware ` $allowed_data_dirs ` for specifying
54+ allowed data-dirs
55+ * Introduced new exceptions: ` DataDirectoryIsNotAllowed ` , ` IPParsingException `
56+ * Implemented the shortcut for the "InitConfig". Now instead of
57+ ` $config = PHP::getInitConfig() ` you can use a shortcut ` $config = ic() `
58+ * Fixed some of the logic related to "l10n" and "default_tz" more you can find here:
59+ [ Nuances of l10n and default_tz] ( docs/notes.md#Nuances-of-l10n-and-default_tz )
60+ * Implemented list of ** days of the week** : ` \spaf\simputils\DT::getListOfDaysOfWeek() `
61+ * Implemented list of ** months** : ` \spaf\simputils\DT::getListOfMonths() `
62+ * Incorporated all the previous minor-version patches
63+ * To set the timezone for "DateTime" object now can be done by "strings" instead of
64+ creation of "DateTimeZone" object every single time
65+ * Other minimal changes
66+ * Implemented trait ` \spaf\simputils\traits\ComparablesTrait ` which enables to implement
67+ common set of comparing functionality (` equalsTo ` , ` greaterThan ` , ` lessThan ` ,
68+ ` greaterThanEqual ` , ` lessThanEqual ` ) and their shortcuts (` e ` , ` gt ` , ` lt ` ,
69+ ` gte ` , ` lte ` ). Currently used in ` Version ` and ` IPv4 ` models
70+ * Implemented ` \spaf\simputils\models\IPv4 ` and ` \spaf\simputils\models\IPv4Range ` models
71+ with minimal but nice functionality
72+ * Implemented ` \spaf\simputils\models\UrlObject ` model
73+ and ` \spaf\simputils\models\urls\processors\HttpProtocolProcessor `
74+ * The most of the stuff should work out of the box except lack
75+ of "to punycode" conversion. Cyrillic and other non-latin domains are
76+ not converted to punycode.
77+ * Implemented ` \spaf\simputils\System::localIp() ` that gets the local IP
78+ * Implemented shortcuts ` url() ` for ` \spaf\simputils\models\UrlObject ` model and
79+ ` ip() ` for ` \spaf\simputils\models\IPv4 `
80+ * Added ` \spaf\simputils\components\normalizers\IPNormalizer ` property normalizer
81+ * Implementation of ` \spaf\simputils\PHP::bro() ` method (` \spaf\simputils\models\BoxRO ` )
82+ which is basically "immutable Box"
83+ * Implemented shortcuts for getting ` POST ` and ` GET ` data as bros (BoxRO). Please keep
84+ in mind that they are immutable due to best-practices:
85+ * ` \spaf\simputils\PHP::POST() `
86+ * ` \spaf\simputils\PHP::GET() `
87+ * Implemented ` \spaf\simputils\PHP::objToNaiveString() ` method to generate simple/naive
88+ object representation
89+ * Implemented some relevant tests
90+ * Important: Functionality of the Box is slightly extended. Now you can re-define static
91+ ` \spaf\simputils\models\Box::$default_separator ` variable value to string that should be used
92+ during ` \spaf\simputils\models\Box::join() ` and ` \spaf\simputils\models\Box::implode() ` as
93+ a separator by default (initially default is ", " as it was before).
94+ Additionally you can specify ` \spaf\simputils\models\Box::$separator ` on per object basis
95+ that will be used in the object in case of "join" or "implode" without the first argument.
96+ That functionality allows to create "path-ready" Box-arrays, that can by default
97+ be automatically converted into a "unix" path.
98+ ` \spaf\simputils\models\Box::$joined_to_str ` per object variable allows to define that
99+ this Box-object needs to be converted in ` __toString() ` method
100+ through ` \spaf\simputils\models\Box::join() ` method, which is really useful for "path-ready"
101+ Box-arrays. See example here: [ Path-alike Box-array] ( #Path-alike-Box-array )
102+ * For convenience create method-shortcut
103+ to set Box as "Path-alike": ` \spaf\simputils\models\Box::pathAlike() `
104+
105+
41106----
42107
43108## Documentation
@@ -51,14 +116,15 @@ so documentation will come after that in the very nearest time. My apologies.
51116### Some:
52117 1 . [ Glossary] ( docs/glossary.md )
53118 2 . [ Structure] ( docs/structure.md )
119+ 3 . [ Important notes] ( docs/notes.md ) - this can help with troubleshooting
54120
55121----
56122
57123## Installation
58124
59125Minimal PHP version: ** 8.0**
60126
61- Current framework version: ** 1.0.5 **
127+ Current framework version: ** 1.1.0 **
62128``` shell
63129composer require spaf/simputils " ^1"
64130```
@@ -75,6 +141,8 @@ Just a few tini-tiny examples of very condensed functionality :)
751411 . [ Properties] ( #Properties )
761422 . [ Date Times] ( #Date-Times )
771433 . [ Advanced PHP Info Object] ( #Advanced-PHP-Info-Object )
144+ 4 . [ IPv4 model] ( #IPv4-model )
145+ 5 . [ Path-alike Box-array] ( #Path-alike-Box-array )
78146
79147### Properties
80148
@@ -496,6 +564,77 @@ You can access top-level fields (those that directly on the object):
496564 }
497565 ```
498566
567+ ### IPv4 model
568+
569+ Simple example:
570+ ``` php
571+
572+ $ic = PHP::init([
573+ 'l10n' => 'AT',
574+ ]);
575+
576+ /**
577+ * @property ?string $name
578+ * @property ?IPv4 $my_ip
579+ */
580+ class Totoro extends SimpleObject {
581+
582+ #[Property]
583+ protected ?string $_name = null;
584+
585+ #[Property]
586+ protected ?IPv4 $_my_ip = null;
587+
588+ }
589+
590+ $t = new Totoro;
591+
592+ $t->name = 'Totoro';
593+ $t->my_ip = '127.0.0.1/16';
594+ $t->my_ip->output_with_mask = false;
595+
596+ pr("I am {$t->name} and my address is {$t->my_ip} (and ip-mask is {$t->my_ip->mask})");
597+
598+ ```
599+
600+ The output would be:
601+ ```
602+ I am Totoro and my address is 127.0.0.1 (and ip-mask is 255.255.0.0)
603+ ```
604+
605+ ### Path-alike Box-array
606+
607+ This is a new feature for ` Box ` model/
608+
609+ ``` php
610+ $b = new Box(['TEST', 'PATH', 'alike', 'box']);
611+
612+ pr("{$b}"); // In this case JSON
613+
614+ $b->joined_to_str = true;
615+
616+ pr("{$b}");
617+
618+ $b->separator = '/';
619+
620+ pr("{$b}");
621+
622+ $b->separator = ' ## ';
623+
624+ pr("{$b}");
625+
626+ ```
627+
628+ The output would be:
629+ ```
630+
631+ ["TEST","PATH","alike","box"]
632+ TEST, PATH, alike, box
633+ TEST/PATH/alike/box
634+ TEST ## PATH ## alike ## box
635+
636+ ```
637+
499638## Additional benefits
5006391 . All the versions are wrapped into ` Version ` class (out of the box version comparison, etc.)
5016402 . The object is created once, and can be accessed through ` PHP::info() `
0 commit comments