Jump to content
php.lv forumi

nedarbojas laravel, nav pieejas mapēm


maarc93

Recommended Posts

Atverot saitu, parādās šis:

file_put_contents(/tmp/1a827dc1b4e548626bb6c57ac4a97f7c): failed to open stream: No such file or directory

 

iegooglējot sapratu, ka nav pieejas config un public mapei. Mēģināju noņemt read-only, bet nav iespējams. Kāds ir saskāries ar šo un tici galā?

OS - Windows 

Link to comment
Share on other sites

 

   /**

     * Write the contents of a file.
     *
     * @param  string  $path
     * @param  string  $contents
     * @param  bool  $lock
     * @return int
     */
    public function put($path, $contents, $lock = false)
    {
        return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
    }

 

šī funkcija izraisa problēmas. $path vietā ieliku funkciju sys_get_temp_dir() un rāda to pašu - file_put_contents(C:\Windows\TEMP): failed to open stream: Permission denied 

Link to comment
Share on other sites

file_put_contents(/tmp/1a827dc1b4e548626bb6c57ac4a97f7c):

 

Man uz windows visi faila vārdi sākas ar c:/ vai d:/.... varbūt tu šajā gadījumā padod linuxīgu faila vārdu un tāpēc tev izmet error No such file or directory

 

 

sys_get_temp_dir() -> DIR! Direktorija

 

Skatamies php manuālī funkciju file_put_contents. Redzam, ka pirmais parametrs ir FILENAME!

int file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] ) -> FILENAME!

 

Bet tu funkcijai file_put_contents padod direktoriju

 

 

 

 

Vispār visiem jaunajiem censoņiem iesaku iemācīties lokalizēt problēmu! Tik pat labi "nedarbojas laravel" vietā varēji rakstīt "nedarbojas dators" vai "nedarbojas zemeslode"

Edited by Kasspars
Link to comment
Share on other sites

Man echo sys_get_temp_dir(); izvada "C:\Users\{myusername}\AppData\Local\Temp". Un man ir admin acc.

Cik es saprotu, šī funkcija čeko environment variabli TEMP. Ja tas nav definēts aktīvajam lietotājam, tad izmanto sistēmas TEMP.

Edited by jurchiks
Link to comment
Share on other sites

Tas tad visiem ir skaidrs. Oriģinālajā postā autors arī padeva full path incl. filename, problēma tikai tajā, ka viņš padod hardcoded linux path uz windows mašīnas.

Vai arī viņam ir sačakarēts TEMP environment variablis.

Vai arī tas ir domāts relative path, in which case you dun goof'd, autor.

Edited by jurchiks
Link to comment
Share on other sites

Man sys_get_temp_dir() izvada C:\Windows\TEMP. 

2zyagzk.png

 

bet dīvaini, ka man ir cits laravel projekts, kurā šāda problēma nav. Un ja ievadu manuāli $path vietā "C:\Users\{myusername}\AppData\Local\Temp", tad rāda - file_put_contents(C:\Users\Marcis\AppData\Local\Temp): failed to open stream: Permission denied

 

pamēģināju uz linux palaist lapu, bet rāda 500 server error. /var/log/apache2/error.log rāda šo:

[Wed Nov 04 14:30:22.191672 2015] [:error] [pid 3606] [client 127.0.0.1:50649] PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/projektaNos/storage/logs/laravel-2015-11-04.log" could not be opened: failed to open stream: Permission denied' in /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87\nStack trace:\n#0 /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(88): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\RotatingFileHandler->write(Array)\n#2 /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Logger.php(289): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#3 /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Logger.php(565): Monolog\\Logger->addRecord(400, Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#4 /var/www/projektaNos/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(50): Monolog\\Logger->error(Ob in /var/www/projektaNos/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 87
Edited by maarc93
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...