3 namespace Friendica\Factory;
6 use Friendica\Core\Config\Cache\PConfigCache;
8 use Friendica\Util\BasePath;
9 use Friendica\Util\BaseURL;
10 use Friendica\Util\Config;
12 class DependencyFactory
15 * Setting all default-dependencies of a friendica execution
17 * @param string $channel The channel of this execution
18 * @param string $directory The base directory
19 * @param bool $isBackend True, if it's a backend execution, otherwise false (Default true)
21 * @return App The application
25 public static function setUp($channel, $directory, $isBackend = true)
27 $basePath = BasePath::create($directory, $_SERVER);
28 $mode = new App\Mode($basePath);
29 $router = new App\Router();
30 $configLoader = new Config\ConfigFileLoader($basePath, $mode);
31 $configCache = Factory\ConfigFactory::createCache($configLoader);
32 $profiler = Factory\ProfilerFactory::create($configCache);
33 $database = Factory\DBFactory::init($configCache, $profiler, $_SERVER);
34 $config = Factory\ConfigFactory::createConfig($configCache);
35 // needed to call PConfig::init()
36 Factory\ConfigFactory::createPConfig($configCache, new PConfigCache());
37 $logger = Factory\LoggerFactory::create($channel, $database, $config, $profiler);
38 Factory\LoggerFactory::createDev($channel, $config, $profiler);
39 $baseURL = new BaseURL($config, $_SERVER);
41 return new App($database, $config, $mode, $router, $baseURL, $logger, $profiler, $isBackend);