public/index.php line 5

Open in your IDE?
  1. <?php
  2. use App\Kernel;
  3. require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
  4. return function (array $context) {
  5. // Function to check if we're running inside a Docker container
  6. function isRunningInDocker(): bool {
  7. return (
  8. file_exists('/.dockerenv') || // Check for Docker environment file
  9. (getenv('DOCKER_CONTAINER') !== false)
  10. );
  11. }
  12. // Only attempt to set permissions if we're NOT in Docker
  13. if (! isRunningInDocker()) {
  14. $basePath = dirname(__DIR__);
  15. $files = [
  16. 'env' => $basePath . '/.env',
  17. 'var' => $basePath . '/var',
  18. 'config' => $basePath . '/config',
  19. 'public' => $basePath . '/public',
  20. 'migrations' => $basePath . '/migrations',
  21. ];
  22. foreach ($files as $key => $file) {
  23. if (file_exists($file)) {
  24. try {
  25. chmod($file, 0775);
  26. } catch (\Exception $e) {
  27. // Log the error if you have a logger configured
  28. error_log("Failed to set permissions for {$key}: " . $e->getMessage());
  29. }
  30. }
  31. }
  32. }
  33. return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
  34. };