A
A
Artem2015-01-03 23:18:46
PHP
Artem, 2015-01-03 23:18:46

How to implement the correct connection of classes in a PHP project?

Project - RESTfull API.
A router is used, class functions are called something like this (Slim framework):

class Foo {
      public function bar ($request, $response, $args) {
             echo "Test";
      }
    }
// GET '/foo/bar'
    $app->get('foo/bar', '\Foo:bar');

There are a lot of classes. How to connect them correctly? Just including everything in index.php, I think it would be wrong..
I would not want to use __autoload for security reasons (I still don’t understand why it’s unsafe, but the note in the documentation is scary) If there is a way to implement this safely, it would be cool.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry S, 2015-01-03
@ber_enot

php.net/manual/en/function.spl-autoload-register.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question