2b79f2c4631396e03435e4be55c536a84b062815
[core.git] / framework / bootstrap / class_FrameworkBootstrap.php
1 <?php
2 // Own namespace
3 namespace CoreFramework\Bootstrap;
4
5 // Import framework stuff
6 use CoreFramework\Configuration\FrameworkConfiguration;
7 use CoreFramework\Connection\Database\DatabaseConnection;
8 use CoreFramework\Connector\Database\DatabaseConnector;
9 use CoreFramework\Console\Tools\ConsoleTools;
10 use CoreFramework\EntryPoint\ApplicationEntryPoint;
11 use CoreFramework\Factory\ObjectFactory;
12 use CoreFramework\Generic\NullPointerException;
13 use CoreFramework\Helper\Application\ApplicationHelper;
14 use CoreFramework\Loader\ClassLoader;
15 use CoreFramework\Manager\ManageableApplication;
16 use CoreFramework\Middleware\Debug\DebugMiddleware;
17 use CoreFramework\Object\BaseFrameworkSystem;
18 use CoreFramework\Registry\Registry;
19 use CoreFramework\Request\Requestable;
20 use CoreFramework\Response\Responseable;
21
22 // Import SPL stuff
23 use \BadMethodCallException;
24 use \InvalidArgumentException;
25 use \SplFileInfo;
26
27 /**
28  * A framework-bootstrap class which helps the frameworks to bootstrap ... ;-)
29  *
30  * @author              Roland Haeder <webmaster@ship-simu.org>
31  * @version             0.0.0
32  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
33  * @license             GNU GPL 3.0 or any newer version
34  * @link                http://www.ship-simu.org
35  *
36  * This program is free software: you can redistribute it and/or modify
37  * it under the terms of the GNU General Public License as published by
38  * the Free Software Foundation, either version 3 of the License, or
39  * (at your option) any later version.
40  *
41  * This program is distributed in the hope that it will be useful,
42  * but WITHOUT ANY WARRANTY; without even the implied warranty of
43  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
44  * GNU General Public License for more details.
45  *
46  * You should have received a copy of the GNU General Public License
47  * along with this program. If not, see <http://www.gnu.org/licenses/>.
48  */
49 final class FrameworkBootstrap {
50
51         /**
52          * Detected server address
53          */
54         private static $serverAddress = NULL;
55
56         /**
57          * Instance of a Requestable class
58          */
59         private static $requestInstance = NULL;
60
61         /**
62          * Instance of a Responseable class
63          */
64         private static $responseInstance = NULL;
65
66         /**
67          * Instance of a FrameworkConfiguration class
68          */
69         private static $configurationInstance = NULL;
70
71         /*
72          * Includes applications may have. They will be tried in the given order,
73          * some will become soon deprecated.
74          */
75         private static $configAppIncludes = array(
76                 // The ApplicationHelper class (required)
77                 'class_ApplicationHelper' => 'required',
78                 // Some debugging stuff (optional but can be committed)
79                 'debug'                   => 'optional',
80                 // Application's exception handler (optional but can be committed)
81                 'exceptions'              => 'optional',
82                 // Application's configuration file (committed, non-local specific)
83                 'config'                  => 'required',
84                 // Local configuration file (optional, not committed, listed in .gitignore)
85                 'config-local'            => 'optional',
86                 // Application data (deprecated)
87                 'data'                    => 'deprecated',
88                 // Application loader (deprecated)
89                 'loader'                  => 'deprecated',
90                 // Application initializer (deprecated)
91                 'init'                    => 'deprecated',
92                 // Application starter (deprecated)
93                 'starter'                 => 'deprecated',
94         );
95
96         /**
97          * Private constructor, no instance is needed from this class as only
98          * static methods exist.
99          */
100         private function __construct () {
101                 // Prevent making instances from this "utilities" class
102         }
103
104         /**
105          * Some "getter" for a configuration instance, making sure, it is unique
106          *
107          * @return      $configurationInstance  An instance of a FrameworkConfiguration class
108          */
109         public static function getConfigurationInstance () {
110                 // Is the instance there?
111                 if (is_null(self::$configurationInstance)) {
112                         // Init new instance
113                         self::$configurationInstance = new FrameworkConfiguration();
114                 } // END - if
115
116                 // Return it
117                 return self::$configurationInstance;
118         }
119
120         /**
121          * Getter for request instance
122          *
123          * @return      $requestInstance        An instance of a Requestable class
124          */
125         public static function getRequestInstance () {
126                 return self::$requestInstance;
127         }
128
129         /**
130          * Getter for response instance
131          *
132          * @return      $responseInstance       An instance of a Responseable class
133          */
134         public static function getResponseInstance () {
135                 return self::$responseInstance;
136         }
137
138         /**
139          * "Getter" to get response/request type from analysis of the system.
140          *
141          * @return      $requestType    Analyzed request type
142          */
143         public static function getRequestTypeFromSystem () {
144                 // Default is console
145                 $requestType = 'console';
146
147                 // Is 'HTTP_HOST' set?
148                 if (isset($_SERVER['HTTP_HOST'])) {
149                         // Then it is a HTML response/request.
150                         $requestType = 'html';
151                 } // END - if
152
153                 // Return it
154                 return $requestType;
155         }
156
157         /**
158          * Checks whether the given file/path is in open_basedir(). This does not
159          * gurantee that the file is actually readable and/or writeable. If you need
160          * such gurantee then please use isReadableFile() instead.
161          *
162          * @param       $fileInstance   An instance of a SplFileInfo class
163          * @return      $isReachable    Whether it is within open_basedir()
164          */
165         public static function isReachableFilePath (SplFileInfo $fileInstance) {
166                 // Is not reachable by default
167                 $isReachable = false;
168
169                 // Get open_basedir parameter
170                 $openBaseDir = trim(ini_get('open_basedir'));
171
172                 // Is it set?
173                 if (!empty($openBaseDir)) {
174                         // Check all entries
175                         foreach (explode(PATH_SEPARATOR, $openBaseDir) as $dir) {
176                                 // Check on existence
177                                 if (substr($fileInstance->getPathname(), 0, strlen($dir)) == $dir) {
178                                         // Is reachable
179                                         $isReachable = true;
180
181                                         // Abort lookup as it has been found in open_basedir
182                                         break;
183                                 } // END - if
184                         } // END - foreach
185                 } else {
186                         // If open_basedir is not set, all is allowed
187                         $isReachable = true;
188                 }
189
190                 // Return status
191                 return $isReachable;
192         }
193
194         /**
195          * Checks whether the give file is within open_basedir() (done by
196          * isReachableFilePath()), is actually a file and is readable.
197          *
198          * @param       $fileInstance   An instance of a SplFileInfo class
199          * @return      $isReadable             Whether the file is readable (and therefor exists)
200          */
201         public static function isReadableFile (SplFileInfo $fileInstance) {
202                 // Default is not readable
203                 $isReadable = false;
204
205                 // Check if it is a file and readable
206                 $isReadable = (
207                         (
208                                 self::isReachableFilePath($fileInstance)
209                         ) && (
210                                 $fileInstance->isFile()
211                         ) && (
212                                 $fileInstance->isReadable()
213                         )
214                 );
215
216                 // Return status
217                 return $isReadable;
218         }
219
220         /**
221          * Loads given include file
222          *
223          * @param       $fileInstance   An instance of a SplFileInfo class
224          * @return      void
225          * @throws      InvalidArgumentException        If file was not found or not readable or deprecated
226          */
227         public static function loadInclude (SplFileInfo $fileInstance) {
228                 // Trace message
229                 //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fileInstance);
230
231                 // Should be there ...
232                 if (!self::isReadableFile($fileInstance)) {
233                         // Abort here
234                         throw new InvalidArgumentException(sprintf('Cannot find fileInstance.pathname=%s.', $fileInstance->getPathname()));
235                 } // END - if
236
237                 // Load it
238                 require $fileInstance->getPathname();
239
240                 // Trace message
241                 //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
242         }
243
244         /**
245          * Does the actual bootstrap
246          *
247          * @return      void
248          */
249         public static function doBootstrap () {
250                 // Load basic include files to continue bootstrapping
251                 self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sclass_FrameworkInterface.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
252                 self::loadInclude(new SplFileInfo(sprintf('%smain%sclasses%sclass_BaseFrameworkSystem.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
253                 self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sregistry%sclass_Registerable.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
254                 self::loadInclude(new SplFileInfo(sprintf('%sconfig%sclass_FrameworkConfiguration.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR)));
255
256                 // Load global configuration
257                 self::loadInclude(new SplFileInfo(sprintf('%s%s', ApplicationEntryPoint::detectFrameworkPath(), 'config-global.php')));
258         }
259
260         /**
261          * Initializes the framework by scanning for all framework-relevant
262          * classes, interfaces and exception. Then determine the request type and
263          * initialize a Requestable instance which will then contain all request
264          * parameter, also from CLI. Next step is to validate the application
265          * (very basic).
266          *
267          * @return      void
268          */
269         public static function initFramework () {
270                 /**
271                  * 1) Load class loader and scan framework classes, interfaces and
272                  *    exceptions.
273                  */
274                 self::scanFrameworkClasses();
275
276                 /*
277                  * 2) Determine the request type, console or web and store request and
278                  *    response here. This also initializes the request instance will
279                  *    all given parameters (see doc-tag for possible sources of
280                  *    parameters).
281                  */
282                 self::determineRequestType();
283
284                 /*
285                  * 3) Now, that there are all request parameters being available, check
286                  *    if 'app' is supplied. If it is not found, abort execution, if
287                  *    found, continue below with next step.
288                  */
289                 self::validateApplicationParameter();
290         }
291
292         /**
293          * Initializes the detected application. This may fail if required files
294          * are not found in the application's base path (not to be confused with
295          * 'application_base_path' which only points to /some/foo/application/.
296          *
297          * @return      void
298          */
299         public static function prepareApplication () {
300                 // Configuration entry 'detected_app_name' must be set, get it here, including full path
301                 $application = self::getConfigurationInstance()->getConfigEntry('detected_app_name');
302                 $fullPath    = self::getConfigurationInstance()->getConfigEntry('detected_full_app_path');
303
304                 /*
305                  * Now check and load all files, found deprecated files will throw a
306                  * warning at the user.
307                  */
308                 foreach (self::$configAppIncludes as $fileName => $status) {
309                         // Construct file instance
310                         $fileInstance = new SplFileInfo(sprintf('%s%s.php', $fullPath, $fileName));
311
312                         // Determine if this file is wanted/readable/deprecated
313                         if (($status == 'required') && (!self::isReadableFile($fileInstance))) {
314                                 // Nope, required file cannot be found/read from
315                                 ApplicationEntryPoint::exitApplication(sprintf('Application "%s" does not have required file "%s.php". Please add it.', $application, $fileInstance->getBasename()));
316                         } elseif (($fileInstance->isFile()) && (!$fileInstance->isReadable())) {
317                                 // Found, not readable file
318                                 ApplicationEntryPoint::exitApplication(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileInstance->getBasename(), $application));
319                         } elseif (($status != 'required') && (!self::isReadableFile($fileInstance))) {
320                                 // Not found but optional/deprecated file, skip it
321                                 continue;
322                         }
323
324                         // Is the file deprecated?
325                         if ($status == 'deprecated') {
326                                 // Issue warning
327                                 trigger_error(sprintf('Deprecated file "%s.php" found, will not load it to avoid problems. Please remove it from your application "%s" to avoid this warning.', $fileName, $application), E_USER_WARNING);
328
329                                 // Skip loading deprecated file
330                                 continue;
331                         } // END - if
332
333                         // Load it
334                         self::loadInclude($fileInstance);
335                 } // END - foreach
336
337                 // Scan for application's classes, exceptions and interfaces
338                 ClassLoader::scanApplicationClasses();
339         }
340
341         /**
342          * Starts a fully initialized application, the class ApplicationHelper must
343          * be loaded at this point.
344          *
345          * @return      void
346          */
347         public static function startApplication () {
348                 // Configuration entry 'detected_app_name' must be set, get it here
349                 $application = self::getConfigurationInstance()->getConfigEntry('detected_app_name');
350
351                 // Is there an application helper instance?
352                 $applicationInstance = call_user_func_array(
353                         array(
354                                 'CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
355                         ), array()
356                 );
357
358                 // Some sanity checks
359                 if ((empty($applicationInstance)) || (is_null($applicationInstance))) {
360                         // Something went wrong!
361                         ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the helper class <span class="class_name">%s</span> is not loaded.',
362                                 $application,
363                                 'CoreFramework\Helper\Application\ApplicationHelper'
364                         ));
365                 } elseif (!is_object($applicationInstance)) {
366                         // No object!
367                         ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because &#39;app&#39; is not an object (%s).',
368                                 $application,
369                                 gettype($applicationInstance)
370                         ));
371                 } elseif (!($applicationInstance instanceof ManageableApplication)) {
372                         // Missing interface
373                         ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because &#39;app&#39; is lacking required interface ManageableApplication.',
374                                 $application
375                         ));
376                 }
377
378                 // Set it in registry
379                 Registry::getRegistry()->addInstance('app', $applicationInstance);
380
381                 // Now call all methods in one go
382                 foreach (array('setupApplicationData', 'initApplication', 'launchApplication') as $methodName) {
383                         // Debug message
384                         //* NOISY-DEBUG: */ printf('[%s:%d]: Calling methodName=%s ...' . PHP_EOL, __METHOD__, __LINE__, $methodName);
385
386                         // Call method
387                         call_user_func(array($applicationInstance, $methodName));
388                 } // END - foreach
389         }
390
391         /**
392          * Initializes database instance, no need to double-call this method
393          *
394          * @return      void
395          */
396         public static function initDatabaseInstance () {
397                 // Get application instance
398                 $applicationInstance = ApplicationHelper::getSelfInstance();
399
400                 // Is the database instance already set?
401                 if ($applicationInstance instanceof DatabaseConnector) {
402                         // Yes, then abort here
403                         throw new BadMethodCallException('Method called twice.');
404                 } // END - if
405
406                 // Initialize database layer
407                 $databaseInstance = ObjectFactory::createObjectByConfiguredName(self::getConfigurationInstance()->getConfigEntry('database_type') . '_class');
408
409                 // Prepare database instance
410                 $connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
411
412                 // Set it in application helper
413                 $applicationInstance->setDatabaseInstance($connectionInstance);
414         }
415
416         /**
417          * Detects the server address (SERVER_ADDR) and set it in configuration
418          *
419          * @return      $serverAddress  The detected server address
420          * @throws      UnknownHostnameException        If SERVER_NAME cannot be resolved to an IP address
421          * @todo        Have to check some more entries from $_SERVER here
422          */
423         public static function detectServerAddress () {
424                 // Is the entry set?
425                 if (!isset(self::$serverAddress)) {
426                         // Is it set in $_SERVER?
427                         if (!empty($_SERVER['SERVER_ADDR'])) {
428                                 // Set it from $_SERVER
429                                 self::$serverAddress = $_SERVER['SERVER_ADDR'];
430                         } elseif (isset($_SERVER['SERVER_NAME'])) {
431                                 // Resolve IP address
432                                 $serverIp = ConsoleTools::resolveIpAddress($_SERVER['SERVER_NAME']);
433
434                                 // Is it valid?
435                                 if ($serverIp === false) {
436                                         /*
437                                          * Why is gethostbyname() returning the host name and not
438                                          * false as many other PHP functions are doing? ;-(
439                                          */
440                                         throw new UnknownHostnameException(sprintf('Cannot resolve "%s" to an IP address. Please fix your setup.', $_SERVER['SERVER_NAME']));
441                                 } // END - if
442
443                                 // Al fine, set it
444                                 self::$serverAddress = $serverIp;
445                         } else {
446                                 // Run auto-detecting through console tools lib
447                                 self::$serverAddress = ConsoleTools::acquireSelfIpAddress();
448                         }
449                 } // END - if
450
451                 // Return it
452                 return self::$serverAddress;
453         }
454
455         /**
456          * Setter for default time zone (must be correct!)
457          *
458          * @param       $timezone       The timezone string (e.g. Europe/Berlin)
459          * @return      $success        If timezone was accepted
460          * @throws      NullPointerException    If $timezone is NULL
461          * @throws      InvalidArgumentException        If $timezone is empty
462          */
463         public static function setDefaultTimezone ($timezone) {
464                 // Is it null?
465                 if (is_null($timezone)) {
466                         // Throw NPE
467                         throw new NullPointerException(NULL, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
468                 } elseif (!is_string($timezone)) {
469                         // Is not a string
470                         throw new InvalidArgumentException(sprintf('timezone[]=%s is not a string', gettype($timezone)));
471                 } elseif ((is_string($timezone)) && (empty($timezone))) {
472                         // Entry is empty
473                         throw new InvalidArgumentException('timezone is empty');
474                 }
475
476                 // Default success
477                 $success = FALSE;
478
479                 /*
480                  * Set desired time zone to prevent date() and related functions to
481                  * issue an E_WARNING.
482                  */
483                 $success = date_default_timezone_set($timezone);
484
485                 // Return status
486                 return $success;
487         }
488
489         /**
490          * Checks whether HTTPS is set in $_SERVER
491          *
492          * @return      $isset  Whether HTTPS is set
493          * @todo        Test more fields
494          */
495         public static function isHttpSecured () {
496                 return (isset($_SERVER['HTTPS']));
497         }
498
499         /**
500          * Dectect and return the base URL for all URLs and forms
501          *
502          * @return      $baseUrl        Detected base URL
503          */
504         public static function detectBaseUrl () {
505                 // Initialize the URL
506                 $protocol = 'http';
507
508                 // Do we have HTTPS?
509                 if (self::isHttpSecured()) {
510                         // Add the >s< for HTTPS
511                         $protocol = 's';
512                 } // END - if
513
514                 // Construct the full URL and secure it against CSRF attacks
515                 $baseUrl = sprintf('%s://%s%s', $protocol, self::detectDomain(), self::detectScriptPath());
516
517                 // Return the URL
518                 return $baseUrl;
519         }
520
521         /**
522          * Detect safely and return the full domain where this script is installed
523          *
524          * @return      $fullDomain             The detected full domain
525          */
526         public static function detectDomain () {
527                 // Full domain is localnet.invalid by default
528                 $fullDomain = 'localnet.invalid';
529
530                 // Is the server name there?
531                 if (isset($_SERVER['SERVER_NAME'])) {
532                         // Detect the full domain
533                         $fullDomain = htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES);
534                 } // END - if
535
536                 // Return it
537                 return $fullDomain;
538         }
539
540         /**
541          * Detect safely the script path without trailing slash which is the glue
542          * between "http://your-domain.invalid/" and "script-name.php"
543          *
544          * @return      $scriptPath             The script path extracted from $_SERVER['SCRIPT_NAME']
545          */
546         public static function detectScriptPath () {
547                 // Default is empty
548                 $scriptPath = '';
549
550                 // Is the scriptname set?
551                 if (isset($_SERVER['SCRIPT_NAME'])) {
552                         // Get dirname from it and replace back-slashes with slashes for lame OSes...
553                         $scriptPath = str_replace("\\", '/', dirname($_SERVER['SCRIPT_NAME']));
554                 } // END - if
555
556                 // Return it
557                 return $scriptPath;
558         }
559
560         /**
561          * 1) Loads class scanner and scans all framework's classes and interfaces.
562          * This method also registers the class loader's method autoLoad() for the
563          * SPL auto-load feature. Remember that you can register additional methods
564          * (not functions, please) for other libraries.
565          *
566          * Yes, I know about Composer, but I like to keep my class loader around.
567          * You can always use mine as long as your classes have a namespace
568          * according naming-convention: Vendor\Project\Group[\SubGroup]
569          *
570          * @return      void
571          */
572         private static function scanFrameworkClasses () {
573                 // Include the class loader function
574                 require self::getConfigurationInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
575
576                 // Register auto-load function with the SPL
577                 spl_autoload_register('CoreFramework\Loader\ClassLoader::autoLoad');
578
579                 // Scan for all framework classes, exceptions and interfaces
580                 ClassLoader::scanFrameworkClasses();
581         }
582
583         /**
584          * 2) Determines request/response type and stores the created
585          * request/response instances in this object for later usage.
586          *
587          * @return      void
588          */
589         private static function determineRequestType () {
590                 // Determine request type
591                 $request = self::getRequestTypeFromSystem();
592                 $requestType = self::getRequestTypeFromSystem();
593
594                 // Create a new request object
595                 $requestInstance = ObjectFactory::createObjectByName(sprintf('CoreFramework\Request\%sRequest', BaseFrameworkSystem::convertToClassName($request)));
596
597                 // Remember request instance here
598                 self::setRequestInstance($requestInstance);
599
600                 // Do we have another response?
601                 if ($requestInstance->isRequestElementSet('request')) {
602                         // Then use it
603                         $request = strtolower($requestInstance->getRequestElement('request'));
604                         $requestType = $request;
605                 } // END - if
606
607                 // ... and a new response object
608                 $responseClass = sprintf('CoreFramework\Response\%sResponse', BaseFrameworkSystem::convertToClassName($request));
609                 $responseInstance = ObjectFactory::createObjectByName($responseClass);
610
611                 // Remember response instance here
612                 self::setResponseInstance($responseInstance);
613         }
614
615         /**
616          * 3) Validate parameter 'app' if it is set and the application is there.
617          *
618          * @return      void
619          */
620         private static function validateApplicationParameter () {
621                 // Is the parameter set?
622                 if (!self::getRequestInstance()->isRequestElementSet('app')) {
623                         /*
624                          * Don't continue here, the application 'selector' is no longer
625                          * supported and only existed as an idea to select the proper
626                          * application (by user).
627                          */
628                         ApplicationEntryPoint::exitApplication('No application specified. Please provide a parameter "app" and retry.');
629                 } // END - if
630
631                 // Get it for local usage
632                 $application = self::getRequestInstance()->getRequestElement('app');
633
634                 // Secure it, by keeping out tags
635                 $application = htmlentities(strip_tags($application), ENT_QUOTES);
636
637                 // Secure it a little more with a reg.exp.
638                 $application = preg_replace('/([^a-z0-9_-])+/i', '', $application);
639
640                 // Construct FQPN (Full-Qualified Path Name) for ApplicationHelper class
641                 $applicationPath = sprintf(
642                         '%s%s%s',
643                         self::getConfigurationInstance()->getConfigEntry('application_base_path'),
644                         $application,
645                         DIRECTORY_SEPARATOR
646                 );
647
648                 // Full path for application
649                 // Is the path there? This secures a bit the parameter (from untrusted source).
650                 if ((!is_dir($applicationPath)) || (!is_readable($applicationPath))) {
651                         // Not found or not readable
652                         ApplicationEntryPoint::exitApplication(sprintf('Application "%s" not found.', $application));
653                 } // END - if
654
655                 // Set the detected application's name and full path for later usage
656                 self::getConfigurationInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
657                 self::getConfigurationInstance()->setConfigEntry('detected_app_name'     , $application);
658         }
659         /**
660          * Setter for request instance
661          *
662          * @param       $requestInstance        An instance of a Requestable class
663          * @return      void
664          */
665         private static function setRequestInstance (Requestable $requestInstance) {
666                 self::$requestInstance = $requestInstance;
667         }
668
669         /**
670          * Setter for response instance
671          *
672          * @param       $responseInstance       An instance of a Responseable class
673          * @return      void
674          */
675         private static function setResponseInstance (Responseable $responseInstance) {
676                 self::$responseInstance = $responseInstance;
677         }
678
679 }