Answer the question
In order to leave comments, you need to log in
How crooked is this application architecture?
When writing an answer, please take into account the fact that I just started learning web development, please indicate a more detailed answer to all kinds of "crutches".
It occurred to me to structure some libraries into one package (let's call it Core). It includes libraries Events , Fstream (working with file streams), Errors (actual error handling), Logger (well, I think it’s clear here). I decided to wrap them in one package due to the fact that each library uses another library from the package. It seemed to me that it was a good tone, to structure them, to set logic (The kernel is autonomous, it must be able to work with autoloading and log exceptions, regardless of whether there is a ready-made library for this. The kernel is always sure that it contains functionality for correct operation, which cannot be said for sure when building an application from ready-made third-party libraries ). It is planned that the kernel can be used without changes in different projects, simply adding the necessary libraries using the Kernel API.
Conclusion : The core contains the basic functionality that is used to create any web application, everything else is external libraries that can use the core API to expand its capabilities, etc.
The question arose of how to get instances of classes included in the core and work with them at the application level.
Creating through new Lib () causes me some rejection, because the fact that the specified Lib belongs to the kernel package is not visible to the eye, as a result of which I was visited by the idea to use a kind of transport layer, it will be easier to explain the syntax
$lib = Core::resource('libname', $constructorArg1, $constructorArg2...) //@return Object libname
//Это же далеко не DI или IoC?
<?php
function sumOfInts(int ...$ints)
{
return array_sum($ints);
}
var_dump(sumOfInts(2, '3', 4.1));
$lib = Core::resource('libname', $constructorArg1, $constructorArg2...) //@return Object libname
//Это же далеко не DI или IoC?
Answer the question
In order to leave comments, you need to log in
Do you use namespaces?
Still, try to implement a composer, it will not interfere with learning, because it is not necessary to immediately use all ready-made libraries. For example, you don't have to write such low-level things as file handling and so on.
Still up-to-date the right way .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question