League \ Flysystem \ UnableToWriteFile
Unable to write file at location: anuario.txt. file_put_contents(/var/www/segundoinformesodi.pjedomex.gob.mx/config/../storage/app/anuario.txt): failed to open stream: Read-only file system League\Flysystem\UnableToWriteFile thrown with message "Unable to write file at location: anuario.txt. file_put_contents(/var/www/segundoinformesodi.pjedomex.gob.mx/config/../storage/app/anuario.txt): failed to open stream: Read-only file system" Stacktrace: #12 League\Flysystem\UnableToWriteFile in /var/www/segundoinformesodi.pjedomex.gob.mx/vendor/league/flysystem/src/UnableToWriteFile.php:24 #11 League\Flysystem\UnableToWriteFile:atLocation in /var/www/segundoinformesodi.pjedomex.gob.mx/vendor/league/flysystem/src/Local/LocalFilesystemAdapter.php:122 #10 League\Flysystem\Local\LocalFilesystemAdapter:writeToFile in /var/www/segundoinformesodi.pjedomex.gob.mx/vendor/league/flysystem/src/Local/LocalFilesystemAdapter.php:101 #9 League\Flysystem\Local\LocalFilesystemAdapter:write in /var/www/segundoinformesodi.pjedomex.gob.mx/vendor/league/flysystem/src/Filesystem.php:44 #8 League\Flysystem\Filesystem:write in /var/www/segundoinformesodi.pjedomex.gob.mx/framework/Filesystem/Driver/Driver.php:31 #7 Framework\Filesystem\Driver\Driver:put in /var/www/segundoinformesodi.pjedomex.gob.mx/app/Http/Controllers/DownloadController.php:12 #6 App\Http\Controllers\DownloadController:yearbook in /var/www/segundoinformesodi.pjedomex.gob.mx/framework/Container.php:64 #5 call_user_func in /var/www/segundoinformesodi.pjedomex.gob.mx/framework/Container.php:64 #4 Framework\Container:call in /var/www/segundoinformesodi.pjedomex.gob.mx/framework/Routing/Route.php:118 #3 Framework\Routing\Route:dispatch in /var/www/segundoinformesodi.pjedomex.gob.mx/framework/Routing/Router.php:62 #2 Framework\Routing\Router:dispatch in /var/www/segundoinformesodi.pjedomex.gob.mx/framework/App.php:67 #1 Framework\App:dispatch in /var/www/segundoinformesodi.pjedomex.gob.mx/framework/App.php:36 #0 Framework\App:run in /var/www/segundoinformesodi.pjedomex.gob.mx/public/index.php:7
Stack frames (13)
12
League\Flysystem\UnableToWriteFile
/vendor/league/flysystem/src/UnableToWriteFile.php24
11
League\Flysystem\UnableToWriteFile atLocation
/vendor/league/flysystem/src/Local/LocalFilesystemAdapter.php122
10
League\Flysystem\Local\LocalFilesystemAdapter writeToFile
/vendor/league/flysystem/src/Local/LocalFilesystemAdapter.php101
9
League\Flysystem\Local\LocalFilesystemAdapter write
/vendor/league/flysystem/src/Filesystem.php44
8
League\Flysystem\Filesystem write
/framework/Filesystem/Driver/Driver.php31
7
Framework\Filesystem\Driver\Driver put
/app/Http/Controllers/DownloadController.php12
6
App\Http\Controllers\DownloadController yearbook
/framework/Container.php64
5
call_user_func
/framework/Container.php64
4
Framework\Container call
/framework/Routing/Route.php118
3
Framework\Routing\Route dispatch
/framework/Routing/Router.php62
2
Framework\Routing\Router dispatch
/framework/App.php67
1
Framework\App dispatch
/framework/App.php36
0
Framework\App run
/public/index.php7
/var/www/segundoinformesodi.pjedomex.gob.mx/vendor/league/flysystem/src/UnableToWriteFile.php
namespace League\Flysystem;
 
use RuntimeException;
use Throwable;
 
final class UnableToWriteFile extends RuntimeException implements FilesystemOperationFailed
{
    /**
     * @var string
     */
    private $location = '';
 
    /**
     * @var string
     */
    private $reason;
 
    public static function atLocation(string $location, string $reason = '', Throwable $previous = null): UnableToWriteFile
    {
        $e = new static(rtrim("Unable to write file at location: {$location}. {$reason}"), 0, $previous);
        $e->location = $location;
        $e->reason = $reason;
 
        return $e;
    }
 
    public function operation(): string
    {
        return FilesystemOperationFailed::OPERATION_WRITE;
    }
 
    public function reason(): string
    {
        return $this->reason;
    }
 
    public function location(): string
    {
        return $this->location;
    }
Arguments
  1. "Unable to write file at location: anuario.txt. file_put_contents(/var/www/segundoinformesodi.pjedomex.gob.mx/config/../storage/app/anuario.txt): failed to open stream: Read-only file system"
    
/var/www/segundoinformesodi.pjedomex.gob.mx/vendor/league/flysystem/src/Local/LocalFilesystemAdapter.php
 
    public function writeStream(string $path, $contents, Config $config): void
    {
        $this->writeToFile($path, $contents, $config);
    }
 
    /**
     * @param resource|string $contents
     */
    private function writeToFile(string $path, $contents, Config $config): void
    {
        $prefixedLocation = $this->prefixer->prefixPath($path);
        $this->ensureDirectoryExists(
            dirname($prefixedLocation),
            $this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY))
        );
        error_clear_last();
 
        if (@file_put_contents($prefixedLocation, $contents, $this->writeFlags) === false) {
            throw UnableToWriteFile::atLocation($path, error_get_last()['message'] ?? '');
        }
 
        if ($visibility = $config->get(Config::OPTION_VISIBILITY)) {
            $this->setVisibility($path, (string) $visibility);
        }
    }
 
    public function delete(string $path): void
    {
        $location = $this->prefixer->prefixPath($path);
 
        if ( ! file_exists($location)) {
            return;
        }
 
        error_clear_last();
 
        if ( ! @unlink($location)) {
            throw UnableToDeleteFile::atLocation($location, error_get_last()['message'] ?? '');
        }
/var/www/segundoinformesodi.pjedomex.gob.mx/vendor/league/flysystem/src/Local/LocalFilesystemAdapter.php
    private $mimeTypeDetector;
 
    public function __construct(
        string $location,
        VisibilityConverter $visibility = null,
        int $writeFlags = LOCK_EX,
        int $linkHandling = self::DISALLOW_LINKS,
        MimeTypeDetector $mimeTypeDetector = null
    ) {
        $this->prefixer = new PathPrefixer($location, DIRECTORY_SEPARATOR);
        $this->writeFlags = $writeFlags;
        $this->linkHandling = $linkHandling;
        $this->visibility = $visibility ?: new PortableVisibilityConverter();
        $this->ensureDirectoryExists($location, $this->visibility->defaultForDirectories());
        $this->mimeTypeDetector = $mimeTypeDetector ?: new FinfoMimeTypeDetector();
    }
 
    public function write(string $path, string $contents, Config $config): void
    {
        $this->writeToFile($path, $contents, $config);
    }
 
    public function writeStream(string $path, $contents, Config $config): void
    {
        $this->writeToFile($path, $contents, $config);
    }
 
    /**
     * @param resource|string $contents
     */
    private function writeToFile(string $path, $contents, Config $config): void
    {
        $prefixedLocation = $this->prefixer->prefixPath($path);
        $this->ensureDirectoryExists(
            dirname($prefixedLocation),
            $this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY))
        );
        error_clear_last();
 
        if (@file_put_contents($prefixedLocation, $contents, $this->writeFlags) === false) {
/var/www/segundoinformesodi.pjedomex.gob.mx/vendor/league/flysystem/src/Filesystem.php
        FilesystemAdapter $adapter,
        array $config = [],
        PathNormalizer $pathNormalizer = null
    ) {
        $this->adapter = $adapter;
        $this->config = new Config($config);
        $this->pathNormalizer = $pathNormalizer ?: new WhitespacePathNormalizer();
    }
 
    public function fileExists(string $location): bool
    {
        return $this->adapter->fileExists($this->pathNormalizer->normalizePath($location));
    }
 
    public function write(string $location, string $contents, array $config = []): void
    {
        $this->adapter->write(
            $this->pathNormalizer->normalizePath($location),
            $contents,
            $this->config->extend($config)
        );
    }
 
    public function writeStream(string $location, $contents, array $config = []): void
    {
        /* @var resource $contents */
        $this->assertIsResource($contents);
        $this->rewindStream($contents);
        $this->adapter->writeStream(
            $this->pathNormalizer->normalizePath($location),
            $contents,
            $this->config->extend($config)
        );
    }
 
    public function read(string $location): string
    {
        return $this->adapter->read($this->pathNormalizer->normalizePath($location));
    }
 
/var/www/segundoinformesodi.pjedomex.gob.mx/framework/Filesystem/Driver/Driver.php
        $this->config = $config;
        $this->connect();
    }
 
    abstract protected function connect();
 
    public function list(string $path, bool $recursive = false) : iterable {
        return $this->filesystem->listContents($path, $recursive);
    }
 
    public function exists(string $path) : bool {
        return $this->filesystem->fileExists($path);
    }
 
    public function get(string $path) : string {
        return $this->filesystem->read($path);
    }
 
    public function put(string $path, $value) {
        $this->filesystem->write($path, $value);
        return $this;
    }
 
    public function delete(string $path) {
        $this->filesystem->delete($path);
        return $this;
    }
}
 
?>
 
/var/www/segundoinformesodi.pjedomex.gob.mx/app/Http/Controllers/DownloadController.php
<?php
 
namespace App\Http\Controllers;
 
class DownloadController {
    public function yearbook(){
        if(!app('filesystem')->exists('anuario.txt')){             
            app('filesystem')->put('anuario.txt', '');         
        }
        
        app('filesystem')->put('anuario.txt',             
            (int) app('filesystem')->get('anuario.txt', 0) + 1,         
        );
 
        return redirect('/documents/2ºInformeAnuario.pdf');
    }    
    
    public function document(){
        if(!app('filesystem')->exists('documento.txt')){             
            app('filesystem')->put('documento.txt', '');         
        }
        
        app('filesystem')->put('documento.txt',             
            (int) app('filesystem')->get('documento.txt', 0) + 1,         
        );
 
        return redirect('/documents/2ºInformeDOCUMENTO.pdf');
    }
}
 
?>
 
/var/www/segundoinformesodi.pjedomex.gob.mx/framework/Container.php
 
            if (isset($parameters[$name])) {
                $dependencies[$name] = $parameters[$name];
                continue;
            }
 
            if ($parameter->isDefaultValueAvailable()) {
                $dependencies[$name] = $parameter->getDefaultValue();
                continue;
            }
 
            if ($type instanceof ReflectionNamedType) {
                $dependencies[$name] = $this->resolve($type);
                continue;
            }
 
            throw new InvalidArgumentException("{$name} cannot be resolved");
        }
 
        return call_user_func($callable, ...array_values($dependencies));
    }
 
    private function getReflector($callable)
    {
        if (is_array($callable)) {
            return new ReflectionMethod($callable[0], $callable[1]);
        }
 
        return new ReflectionFunction($callable);
    }
}
 
?>
 
/var/www/segundoinformesodi.pjedomex.gob.mx/framework/Container.php
 
            if (isset($parameters[$name])) {
                $dependencies[$name] = $parameters[$name];
                continue;
            }
 
            if ($parameter->isDefaultValueAvailable()) {
                $dependencies[$name] = $parameter->getDefaultValue();
                continue;
            }
 
            if ($type instanceof ReflectionNamedType) {
                $dependencies[$name] = $this->resolve($type);
                continue;
            }
 
            throw new InvalidArgumentException("{$name} cannot be resolved");
        }
 
        return call_user_func($callable, ...array_values($dependencies));
    }
 
    private function getReflector($callable)
    {
        if (is_array($callable)) {
            return new ReflectionMethod($callable[0], $callable[1]);
        }
 
        return new ReflectionFunction($callable);
    }
}
 
?>
 
/var/www/segundoinformesodi.pjedomex.gob.mx/framework/Routing/Route.php
            $parameterValues += $emptyValues;
 
            $this->parameters = array_combine(
                $parameterNames,
                $parameterValues,
            );
 
            return true;
 
        }
 
        return false;
    }
 
    public function dispatch() {
        if (is_array($this->handler)) {
            [$class, $method] = $this->handler;
 
            if(is_string($class)) {
                return app()->call([new $class, $method]);
            }
 
            return app()->call([$class, $method]);
        }
 
        return app()->call($this->handler);
    }
 
    private function normalisePath(string $path) : string {
        $path = trim($path, '/');
        $path = "/{$path}/";
 
        $path = preg_replace('/[\/]{2,}/', '/', $path);
 
        return $path;
    }
 
}
 
?>
/var/www/segundoinformesodi.pjedomex.gob.mx/framework/Routing/Router.php
 
                return $path;
            }
        }
        throw new Exception('no route with that name');
    }
 
    public function dispatch() {
        $paths = $this->paths();
 
        $requestMethod = $_SERVER['REQUEST_METHOD'] ?? 'GET';
        $requestPath = $_SERVER['REQUEST_URI'] ?? '/';
 
        $matching = $this->match($requestMethod, $requestPath);
 
        if($matching){
            $this->current = $matching;
            
            try {
                return $matching->dispatch();
            }
            catch(Throwable $e){
                $result = null;
                
                if ($handler = config('handlers.exceptions')) {
                    $instance = new $handler();
 
                    if($result = $instance->showThrowable($e)) {
                        return $result;
                    }
                }
 
                return $this->dispatchError();
            }
        }
 
        if(in_array($requestPath, $paths)) {
            return $this->dispatchNotAllowed();
        }
 
/var/www/segundoinformesodi.pjedomex.gob.mx/framework/App.php
 
        foreach ($providers as $provider) {
            $instance = new $provider;
 
            if (method_exists($instance, 'bind')) {
                $instance->bind($this);
            }
        }
    }
 
    private function dispatch(string $basePath)
    {
        $router = new Router();
 
        $this->bind(Router::class, fn() => $router);
 
        $routes = require "{$basePath}/app/routes.php";
        $routes($router);
 
        $response = $router->dispatch();
 
        if(!$response instanceof Response) {
            $response = $this->resolve('response')->content($response);
        }
 
        return $response;
    }
}
 
?>
 
/var/www/segundoinformesodi.pjedomex.gob.mx/framework/App.php
        }
 
        return static::$instance;
    }
 
    private function __construct() {}
    private function __clone() {}
 
    public function prepare() {
        $basePath = $this->resolve('paths.base');
 
        $this->configure($basePath);
        $this->bindProviders($basePath);
 
        return $this;
    }
 
    public function run() : Response
    {
        return $this->prepare()->dispatch($this->resolve('paths.base'));
    }
 
    private function configure(string $basePath)
    {
        $dotenv = Dotenv::createImmutable($basePath);
        $dotenv->load();
    }
 
    private function bindProviders(string $basePath)
    {
        $providers = require "{$basePath}/config/providers.php";
 
        foreach ($providers as $provider) {
            $instance = new $provider;
 
            if (method_exists($instance, 'bind')) {
                $instance->bind($this);
            }
        }
    }
/var/www/segundoinformesodi.pjedomex.gob.mx/public/index.php
<?php
 
require_once __DIR__ . '/../vendor/autoload.php';
 
$app = \Framework\App::getInstance();
$app->bind('paths.base', fn() => __DIR__ . '/../');
$app->run()->send();
 
?>
 

Environment & details:

Key Value
path
"downloadYearbook"
empty
empty
empty
empty
Key Value
REDIRECT_REDIRECT_STATUS
"200"
REDIRECT_STATUS
"200"
HTTP_HOST
"segundoinformesodi.pjedomex.gob.mx"
HTTP_X_REAL_IP
"54.221.43.155"
HTTP_X_FORWARDED_FOR
"54.221.43.155, 54.221.43.155"
HTTP_X_FORWARDED_HOST
"segundoinformesodi.pjedomex.gob.mx"
HTTP_CONNECTION
"close"
HTTP_ACCEPT
"*/*"
HTTP_USER_AGENT
"claudebot"
PATH
"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
SERVER_SIGNATURE
"<address>Apache/2.4.41 (Ubuntu) Server at segundoinformesodi.pjedomex.gob.mx Port 80</address>\n"
SERVER_SOFTWARE
"Apache/2.4.41 (Ubuntu)"
SERVER_NAME
"segundoinformesodi.pjedomex.gob.mx"
SERVER_ADDR
"10.22.157.12"
SERVER_PORT
"80"
REMOTE_ADDR
"10.22.157.21"
DOCUMENT_ROOT
"/var/www/segundoinformesodi.pjedomex.gob.mx"
REQUEST_SCHEME
"http"
CONTEXT_PREFIX
""
CONTEXT_DOCUMENT_ROOT
"/var/www/segundoinformesodi.pjedomex.gob.mx"
SERVER_ADMIN
"webmaster@localhost"
SCRIPT_FILENAME
"/var/www/segundoinformesodi.pjedomex.gob.mx/public/index.php"
REMOTE_PORT
"56691"
REDIRECT_URL
"/index.php"
REDIRECT_QUERY_STRING
"path=downloadYearbook"
GATEWAY_INTERFACE
"CGI/1.1"
SERVER_PROTOCOL
"HTTP/1.0"
REQUEST_METHOD
"GET"
QUERY_STRING
"path=downloadYearbook"
REQUEST_URI
"/downloadYearbook"
SCRIPT_NAME
"/public/index.php"
PHP_SELF
"/public/index.php"
REQUEST_TIME_FLOAT
1711624946.328
REQUEST_TIME
1711624946
APP_ENV
"dev"
EMAIL_ENV
"dev"
DB_HOST
"localhost"
DB_USR
"sisodi"
DB_PWD
"21nF.rm350d1"
DB_NAME
"segundoinformesodi"
Key Value
APP_ENV
"dev"
EMAIL_ENV
"dev"
DB_HOST
"localhost"
DB_USR
"sisodi"
DB_PWD
"21nF.rm350d1"
DB_NAME
"segundoinformesodi"
0. Whoops\Handler\PrettyPageHandler