I
I
ideological2017-10-18 21:13:29
PHP
ideological, 2017-10-18 21:13:29

How to understand OOP PHP library?

We have https://github.com/danog/MadelineProto
a bunch of files divided into subfolders. How to start litigation? In which file is what stored and how is it organized?
I know that OOP is about creating classes, using objects, etc. I write in a class myself, but it's more of a collection of boolean methods with convenience properties and __construct - which is probably not true OOP. Understanding how to do inheritance does not yet help to use it. :(
How do you immediately understand how to use someone else's code? What algorithm do you use? Questions are not for a beautiful word - a real great desire to understand. Please do not pass by.
ps1
In the case of simple functions where they write what is at the input and output, everything is clear. Is it easier to maintain the documentation of the OPP than the documentation of specific functions? If in the future there was a service like github but for functions and they were put in php as easy as installing packages apt install function1 function2 ..; it would be just chicdos. Not?
ps2
The author of the library deliberately omitted several files that the user must create himself, such as not for fools. Is this a conscious, healthy modern approach, or is the author just being rude? https://github.com/danog/MadelineProto/issues/33#i...
ps3
Also an OOP library from facebook https://facebook.github.io/php-webdriver/latest/in... considered well documented, I saw it right, 5 seconds and the code is ready? Or how?
For my tasks it is clear how to use it, just wondering if this is the crown of descriptive detail in the world of OOP or could it be better?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Egor, 2017-10-18
@egormmm

Dude. Any code (library, package, function) - there is some promise of its manufacturer to do something valuable for you. This description must give the name of the class and its method that this result will create. And then - it's not your problem how everything is arranged inside. You create an object, give it something it depends on, and call a method on that object. All!
Imagine a TV. Its manufacturer promises to give you the opportunity to watch TV channels if you connect an antenna. What is your task as a TV user? Correctly! Insert the antenna and press the power button. After all, you will not climb inside the TV with a tester and check how everything is arranged there. The description should tell you where the power button is.
If you use a package (module, library) in which it is not immediately clear, then this is not your problem, but the manufacturer who created it. It's just that they probably didn't come up with anything better, and you either have to create it yourself or use such a G...
The code should be something like this:
$tv = new Tv(new Antena);
$content = $tv->on();
This is what OOP is.

D
D3lphi, 2017-10-18
@D3lphi

How to start litigation? In which file is what stored and how is it organized?

If you want to understand how this library works, what is called for, and so on, then I highly recommend using a debugger (The most popular is xdebug) with some convenient gui (It is present in phpstorm). Put a breakpoint and go ahead to deal with the order of calling a particular method, function, and so on.
We read the documentation on this library.
First of all, it is not documentation support that is important, but code support. And the ease of use.
Do you find it difficult to install libraries in php?
It didn't skip any files. In a comment on the link, he suggests that the programmer of the client code create a configuration file of his choice. The configuration file has nothing to do with the implementation. The client code programmer is free to decide how to configure the objects:
// Так
$someObf = new SomeClass('this_is_example_api_key');

// Или так
$someObf = new SomeClass(require('config.php')['api_key']);

// Или, например, так
$someObf = new SomeClass($config->get('api_key'));

Z
zorca, 2017-10-18
@zorca

Reading documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question