laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.32k stars 10.95k forks source link

ErrorException: Undefined array key 1 #43653

Closed truongvietgroup closed 2 years ago

truongvietgroup commented 2 years ago

Description:

After executing the command:: php artisan serve and access the link: http://127.0.0.1:8000/ I try to access the document file in the public folder and get an error message

2022-08-11 14:44:48 /assets/img/icons/spot-illustrations/bg-shape.png ................................................................................................................................................................................................ ~ 0s 2022-08-11 14:44:48 /assets/img/icons/spot-illustrations/shape-1.png ................................................................................................................................................................................................. ~ 1s WARN [Thu Aug.

2022-08-11 14:44:48 ErrorException

Undefined array key 1

at D:\xampp\htdocs\laratest\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:289 285▕ protected function getDateFromLine($line) 286▕ { 287▕ preg_match('/^[([^]]+)]/', $line, $matches); 288▕ ➜ 289▕ return Carbon::createFromFormat('D M d H:i:s Y', $matches[1]); 290▕ } 291▕ 292▕ /* 293▕ Get the request port from the given PHP server output. PHP server output.

1 D:\xampp\htdocs\laratest\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:289 Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap{closure}("Undefined array key 1", "D:\xampp\htdocs\laratest\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php")

2 D:\xampp\htdocs\laratest\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:260 Illuminate\Foundation\Console\ServeCommand::getDateFromLine(" 11 14:44:49 2022] 127.0.0.1:53586 Closing")

driesvints commented 2 years ago

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

rajatpatelz commented 2 years ago

@driesvints read the issue description properly. This is an issue with the framework only. I am also facing the same problem after the latest update. There is some problem with artisan:serve command.

 ErrorException

  Undefined array key 1

  at E:\xampp\htdocs\laravel-demo\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:289
    285▕     protected function getDateFromLine($line)
    286▕     {
    287▕         preg_match('/^\[([^\]]+)\]/', $line, $matches);
    288▕
  ➜ 289▕         return Carbon::createFromFormat('D M d H:i:s Y', $matches[1]);
    290▕     }
    291▕
    292▕     /**
    293▕      * Get the request port from the given PHP server output.
PHP server output.

  1   E:\xampp\htdocs\laravel-demo\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:289
      Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined array key 1", "E:\xampp\htdocs\laravel-demo\vendor\laravel\framework\src\Illuminate\Foun
dation\Console\ServeCommand.php")

  2   E:\xampp\htdocs\laravel-demo\vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php:239
      Illuminate\Foundation\Console\ServeCommand::getDateFromLine("2022] 127.0.0.1:49876 Accepted")
driesvints commented 2 years ago

@rajatpatelz I don't have any problems running artisan serve on the Latest Laravel version. Please try a support channel.

rajatpatelz commented 2 years ago

Yes It runs initially, but throws the given error after running for a while but not exactly sure when and why. It crashes randomly.

truongvietgroup commented 2 years ago

Yes It runs initially, but throws the given error after running for a while but not exactly sure when and why. It crashes randomly.

Exactly. When I configure via apache, not via command line the problem does not appear. This problem was encountered on windows 7. I tried again on windows 10 and did not encounter the above situation (On the same project).

inxty commented 1 year ago

Maybe it depends on the OS datetime preferences?

roqueguardia commented 9 months ago

I have a similar issue in my Jenkins instance running a Dockerfile, but I don't know if It could be the framework or if It's something related with a broken dependency image

roqueguardia commented 9 months ago

Here is my Dockerfile:

`FROM php:8.2-alpine

Instala php

RUN apk add --no-cache php82 \ php82-common \ php82-fpm \ php82-pdo \ php82-opcache \ php82-zip \ php82-phar \ php82-iconv \ php82-cli \ php82-curl \ php82-openssl \ php82-mbstring \ php82-fileinfo \ php82-json \ php82-xml \ php82-xmlwriter \ php82-simplexml \ php82-dom \ php82-pdo_mysql \ php82-pdo_sqlite \ php82-tokenizer \ php82-pecl-redis \ php82-ldap RUN ln -s /usr/bin/php82 /usr/bin/php RUN apk \ add apache2-ssl \ apache2-utils \ nodejs \ npm \ && rm -f /var/cache/apk/* \ && mkdir /htdocs

Instala composer

RUN curl -sS https://getcomposer.org/installer -o composer-setup.php RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer RUN rm -rf composer-setup.php RUN mkdir /etc/apache2/conf.d/certs COPY /storage/apache/privada.unlam.edu.ar.key /etc/apache2/conf.d/certs/ COPY /storage/apache/publica.unlam.edu.ar.crt /etc/apache2/conf.d/certs/ COPY /storage/apache/php.ini-production /etc/php8/php.ini COPY /storage/apache/httpd-alpine.conf /etc/apache2/httpd.conf COPY /storage/apache/httpd-ssl-alpine.conf /etc/apache2/conf.d/ssl.conf COPY /storage/apache/secret /secret

WORKDIR /var/www/localhost/htdocs

Descarga git y clona repositorio

RUN apk add git RUN git clone https://text@text.git RUN cp -r /var/www/localhost/htdocs/clon_scp/* . RUN rm -r /var/www/localhost/htdocs/clon_scp

COPY /storage/apache/start.sh .

ADD . .

RUN chmod -R 777 storage RUN apk add --no-cache --virtual .gyp python3 make g++ && npm install && apk del .gyp RUN composer self-update --stable RUN php -v COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/

Install PHP extensions

RUN install-php-extensions ldap RUN install-php-extensions gd RUN install-php-extensions zip RUN install-php-extensions pdo RUN install-php-extensions curl RUN install-php-extensions openssl RUN install-php-extensions mbstring RUN install-php-extensions exif RUN install-php-extensions tokenizer RUN install-php-extensions fileinfo RUN install-php-extensions xml RUN install-php-extensions dom RUN php --ini # RUN cat /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini RUN composer update # RUN composer install --optimize-autoloader --no-dev RUN composer require tamer-dev/laravel-env-cli RUN npm config set registry https://registry.npmjs.org/ RUN npm install --global cross-env RUN npm run production

EXPOSE 3000

HEALTHCHECK CMD wget -q --no-cache --spider localhost/index.html

RUN chmod +x start.sh ENTRYPOINT ["./start.sh"]

`