Skip to content

firstruner/GuidClasses

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ› οΈ Framework PHP - Guids Classes

This repository implement a management about Guid/UUID and LUID creations. In sometimes case, "com_create_guid" function isn't available. The Guid class in accordance with the 128 bits norm key (RFC 9562), allow you to create Guid with same function of .Net platform.

Since, Guid V7 et now LUId creation, this repository will evolve in the follow-up of the current and future standard

⚠️ This repository use may be old Firstruner Framework PHP classes, not usely updated

πŸ‘‡ Some notes about Firstruner Framework PHP πŸ‘‡

πŸ› οΈ Framework PHP - Partials functions

This repository include a part of Firstruner Framework for PHP to allow use Partial function with PHP OOP objects

This project is a part of πŸ› οΈ Firstruner Framework for PHP. It contains a little part of the original Framework that allow you to use "partial" DotNet functionality into PHP structure project and also naturally the Framework loader.

To use, it's very simple !

βš—οΈ PHP version

Actually tested on PHP from 7.1.* to 8.3.*

Partials versions


🌞 v1.0 Initial repository
🌞 v1.1 Uses, inheritance and implementations support
🌞 v1.2 Final and Abstract support for classes
πŸ’« v2.0 πŸŽ‡ Features :\

  1. Interfaces, Enumerations and Trait support
  2. Conversion Enum files for PHP >= 8.1 to Abstract class files for PHP >= 7.1
  3. Fix exception on Composer Update (Tested with Symfony and Laravel project)
  4. Integrate array path for loading and ignored function
  5. Implement a fluent class for load partial OOP
  6. Implement log possibilities
  7. Implement delayed loading possibilities

πŸ§™β€β™‚οΈ Loader (main method)

Create a folder that contains all of your POO Objects (classes, interfaces, enumerations and other).

// The only required dependence for use Loader of Firstruner Framework
require __DIR__ . '/System/Reflection/Dependencies/Loader.php';

// For multiple use of Loader class
use System\Reflection\Dependencies\Loader;

// Load all php POO files in "MyOOP" Folder
Loader::Load(__DIR__ . '/MyOOP');

πŸ”° Load function of Loader class can take in 1st argument a single string or an array of string,\

πŸ”° The 4th argument is also take a single string or an array of string to ignore some path in the path scanned. Ignored paths must be a physic path like : c:\httpserver\htdocs\myproject\classes\ingoredClasses

πŸ““ For all other method, go to "All Loader Methods" at the bottom of this documentation πŸ‘‡ or consult pdf include

πŸ§™β€β™‚οΈ Load with FluentLoader

This Firstruner Framework contains also a partial loader which is can use in fluent mode.

// The only required dependence for use FluentLoader of Firstruner Framework
require __DIR__ . '/System/Reflection/Dependencies/FluentLoader.php';

// For simplify usage of FluentLoader class
use System\Reflection\Dependencies\FluentLoader;

// Load all php POO files in "MyOOP_Directory/Classes" and "MyOOP" Folders
$fluentLoader = new FluentLoader();
$fluentLoader->SetLogActivation(true)->Load("MyOOP_Directory/Classes")->SetLogActivation(false)->Add_Including_Path(__DIR__ . '/MyOOP')->LoadStoredPaths();

Notes

πŸ’‘ Pay close attention to the loading order !

πŸ‘‰ Loading note : it's recommended to load elements in this ordre :

  1. Enumerations
  2. Interfaces
  3. Classes

πŸ‘‰ File extension note : For standard use, partial file must have "partial_php" extension, but it's possible to use "php" extension if you specify "php_as_partial" attribute to "True" when "Load" method was called. But use "php" are more lazy because it necessary to load the php file before determine if the file is a partial file.

Performances

πŸ“ˆ For better performances, use partial_php extension for your files and DO NOT set php_as_partial argument in Load function as True.

πŸ“ˆ It recommended if you have a project with multiple target to separate you partial classes of your projects

IDE integration

VS Code

βš™οΈ Go in File menu > Preferences > Settings.
In "File editor" section, add "*.partial_php" use like "php" in file association item vscode-menu.png
vscode-ext.png\

How use Partials on OOP object

πŸ’‘ To create a php files with partials, create a folder for your OOP object, and create all of your files inside.

πŸ‘¨β€πŸ­ Define a OOP file as partial

Call attributes

To define the file as a partial file, you should reference Partials attributes like this :

use System\Attributes\Partial;

Define as partial file

Now define the OOP file as partial with using Partial attribute like this :

#[Partial]

Delayed loading

If you need to load OOP file later, you can specify the element with "delayedLoading" at True, like this :\

#[Partial(true)]
Or
#[Partial(delayedLoading: true)]

For load delayed elements, use "LoadStoredPaths" method or specify at True "loadDelayedElements" argument on "Load" method

πŸ“š Full main partial sample

<?php
namespace System\Printers;

use System\Attributes\Partial;

#[Partial]
class ScreenPrinter
{
      public function PrintInstanceMessage()
      {
            echo "Mon Instance";
      }
}

πŸ”Ž Some samples are present in Samples folder

πŸ“š Sample 1

πŸ“— File 1
namespace  System\Sample;

use System\Attributes\Partial;
use \Exception;

#[Partial]
class  Sample extends MainClass
{
}
πŸ“˜ File 2
namespace  System\Sample;

use System\Attributes\Partial;
use Symfony\Component\
{
	HttpFoundation\Request,
	Routing\Annotation\Route
};

#[Partial]
class  Sample implements OwnInterface
{
}

πŸ“š Sample 2

πŸ“— File 1
namespace  System\Sample;

use System\Attributes\Partial;
use \Exception;

#[Partial]
class  Sample extends MainClass implements 1stInterface, 2ndInterface
{
}
πŸ“˜ File 2
namespace  System\Sample;

use System\Attributes\Partial;
use Symfony\Component\
{
	HttpFoundation\Request,
	Routing\Annotation\Route
};

#[Partial]
class  Sample implements OwnInterface, OtherInterface
{
}

All Loader Methods available from Loader static class or from FluentLoader class

βš“ Load method :\

ℹ️ Main OOP loading method, it can call directly.
✏️ included : Specify path(s) who must be load - Can take string or string array - No default value, Required
✏️ maxTemptatives : Specify the number of loading temptatives - int - default value is 1
✏️ php_as_partial : Specify if partial class is in php files with php extension - Boolean - default value is False
✏️ ignored : Specify path(s) who must be ignored during the loading - Can take string or string array - default value is an empty array
✏️ loadDelayedElements : Specify if the loader load partial class that specified as "delayedLoading" at True - Boolean - default value is Without
OnPost work similar than Without but force loading after non delayed
✏️ loadDelayedElements : Specify object who the loader must load - Default value is PartialEnumerations_ObjectType::All\

βš“ LoadStoredPaths method :\

ℹ️ This method try to load OOP paths that specify with Load method or AddIncludePath
✏️ maxTemptatives : Specify the number of loading temptatives - int - default value is 1
✏️ php_as_partial : Specify if partial class is in php files with php extension - Boolean - default value is False
✏️ loadDelayedElements : Specify object who the loader must load - Default value is PartialEnumerations_ObjectType::All\

βš“ LoadDelayedElements method :\

ℹ️ This method try to load OOP paths that is in delayed mode only
✏️ php_as_partial : Specify if partial class is in php files with php extension - Boolean - default value is False
✏️ loadDelayedElements : Specify object who the loader must load - Default value is PartialEnumerations_ObjectType::All\

βš“ AddIncludePath method :\

ℹ️ This method add OOP paths for Loading. It use before call LoadStoredPaths method
✏️ paths : Specify path(s) who must be load - Can take string or string array - No default value, Required\

βš“ AddIgnorePath method :\

ℹ️ This method add OOP paths who must be ignore during Loading. It use before call LoadStoredPaths method
✏️ paths : Specify path(s) who must be load - Can take string or string array - No default value, Required\

βš“ StandardPHP_LoadDependency method :\

ℹ️ This method try to load as 'require' a specific php file path
✏️ paths : Specify path who must be load - String - No default value, Required
πŸ”” Only available from static class - work also when FluentClass is consume

βš“ SetObjectTypeFilter method :\

ℹ️ This method defun filter loader
✏️ objectType : Specify object who the loader must load - Default value is PartialEnumerations_ObjectType::None, Required
πŸ”” Only available from fluent class

βš“ Clear method :\

ℹ️ This method clear Loader parameters\

βš“ GetLastDependenciesCount method :\

ℹ️ This method return dependencies who were well loaded
πŸ”” Only available from static class - work also when FluentClass is consume

βš“ SetLogActivation method :\

ℹ️ This method specify if Loader use a log during loading
✏️ active : Boolean - No default value, Required\

βš“ GetLog method :\

ℹ️ This method return string array about log events
πŸ”” Only available from static class - work also when FluentClass is consume

Know exceptions

During Composer Update

⚠️ Name is allready in use
Composer-Exception.png

➑️ To solve that, please use partial_php extension for your partial files and use the Firstruner Framework Loader for load these partial files

PHP

⚠️ Name is allready in use
Whats-App-Image-2024-01-22-at-09-38-41.jpg

Solutions :
➑️ Use Firstruner Framework Loader
➑️ Apply partial_php extension on your partial files
➑️ Specify php_as_partial at true on Loader calling

About

Part of Firstruner Framework for PHP to allow GUIDs/UUID and LUID creations

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages