Undefined offset at PhpMatcherTrait - php

My project was working perfect. I wanted to write some new lines of code today but it gives me this error.
ErrorException: Notice: Undefined offset: 6
at vendor/symfony/routing/Matcher/Dumper/PhpMatcherTrait.php:87
I have totally no idea what that is.
Checked what I was doing last when it was still working. I tried to configure authentication and registration form so according to tutorial I used these lines in terminal:
composer require symfony/security-csrf
composer require symfony/security-bundle
php bin/console make:user
php bin/console make:migration
php bin/console doctrine:migrations:migrate
composer update
Thats simply everything I did.
I am using Symfony 4.1 and PHP 7.1.3
This is a fresh project, with one view, one controller, it was working fine so far.
Will appreciate any help on this.

I had the same error after doing a composer update. Running php bin/console cache:clear in the terminal resolved it for me.

Seems like that something has updated, - most likely Composer.
Try deleting your vendor folder and do a composer install.

Related

"php bin/console server:run" immediately followed by "composer require symfony/mailer" whenever it is run

I'm working on a Symfony project and would like to know why whenever I run the following command in terminal php bin/console server:run it would be immediately followed by this one composer require symfony/mailer. This is a screenshot of terminal:
Moreover, this is what I get as an output on http://127.0.0.1:8000/:
You can notice that the command text "composer require symfony/mailer" shows at the top of the page.
So, how can I handle that? Any idea?
P.S:
Symfony version: 4.4
PHP version: 8.0.12
IDE: PhpStorm
The issue is finally resolved! Making a search for composer require symfony/mailer (by going to "Edit"->"Find"->"Find in Files" in PhpStorm), I found it added somehow in the bundles.php file.

Laravel 5.5 - Issues creating new project

I'm trying to use Laravel 5.5. I updated my php 7.0 to php 7.1. Even, I update my laravel installer package. But, when I try to do:
laravel new myProject
I get this error:
You made a reference to a non-existent script #php -r
"file_exists('.env') || copy('.env.example', '.env');" You made a
reference to a non-existent script #php artisan key:generate
Illuminate\Foundation\ComposerScripts::postAutoloadDump You made a
reference to a non-existent script #php artisan package:discover
I am using laravel valet and if I go to the browser, when I try myProject.dev is not working. I see this error:
Whoops, looks like something went wrong.
I tried using:
php artisan key:generate
inside my project, but I got that:
[ErrorException]
file_get_contents(/Users/jorgeJimenez/Sites/laravel5-5/.env): failed
to ope n stream
: No such file or directory
I noticed, my laravel 5.4 projects are working. I copied a .env file and I put on my laravel 5.5 projects. After that, I run
php artisan key:generate
and the key was generated and my project in the browser works.
It's supposed, all that process is automatic, but I am not quite sure what is happening.
You can try update your composer:
composer self-update
I had the same problem. Then I found that there was no problem when i created the first project use laravel 5.5. so I clear composer's cache dir. It works well now.
This is because of your Laravel Installer or Composer version. I have faced the same problem and found following 2 different solutions:
Generally you can solve with by running composer global update command and then run composer update command from your project directory. This solution basically updates your installer and then your project.
If still, you have this issue, you need to run composer self-update command first and then run composer update command from your project directory. Here your composer will update and then your project.
Hope this answer will help you.

Error when creating Laravel 5 project

I know there are 2 ways to create a new project in Laravel. One is using composer create-project laravel/laravel _projectname_ and another is using laravel new _projectname_. I tried to create a project using the first one with Composer, and there is no problem with it. But when I tried to create with the second one using laravel new, it returned this error:
$ laravel new _projectname_
Crafting application...
> php -r "copy('.env.example', '.env');"
> php artisan clear-compiled
Script php artisan clear-compiled handling the post-install-cmd
event returned with an error
[RuntimeException]
Error Output:
run-script [--dev] [--no-dev] [-l|--list] [--] [<script>] [<args>]...
Application ready! Build something amazing.
I used Windows as OS and I've set the environment PATH for %USERPROFILE%\AppData\Roaming\Composer\vendor\bin in PATH, and it works when I try the laravel commend in the command prompt. I've always used the laravel new _projectname_ before and it worked. I think I changed nothing, but it doesn't work anymore and I don't know why. How could that be? Any help would be appreciated. Thanks.
I've found the answer, i got from this https://laracasts.com/discuss/channels/general-discussion/cant-use-laravel-new-app-name. Update your laravel using composer global require "laravel/installer" . After it finished, tried to run laravel new _projectname_, it update all dependencies and it works for me. Hope it helps.

Fatal error: Class 'Illuminate\Foundation\Application' not found

I am getting following error when I open my site which is made using laravel 5
Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\cms\bootstrap\app.php on line 14
I have tried removing vendor folder and composer.lock file and running composer install it's not working I tried running PHP artisan optimize but it shows error
Fatal error: Class'Illuminate\Foundation\Application' not found
Is there any way to solve this problem?
Edited:
This problem aroused as soon as I used the php artisan make:model Page command which did create the model but then the above error gets displayed when I access the site
Also If use the Laravel's Local Development Server no such problem arises only if I use wamp server
In my situation, I didn't have the full vendor dependencies in place (composer file was messed up during original install) - so running any artisan commands caused a failure.
I was able to use the --no-scripts flag to prevent artisan from executing before it was included. Once my dependencies were in place, everything worked as expected.
composer update --no-scripts
Just in case I trip over this error in 2 weeks again...
My case: Checkout an existing project via git and pull in all dependencies via composer. Came down to the same error listed within the title of this post.
Solution:
composer dump-autoload
composer install --no-scripts
make sure everything works now as expected (no errors!)
composer update
Something is clearly corrupt in your Laravel setup and it is very hard to track without more info about your environment. Usually these 2 commands help you resolve such issues
php artisan clear-compiled
composer dump-autoload
If nothing else helps then I recommend you to install fresh Laravel 5 app and copy your application logic over, it should take around 15 min or so.
Easy as this, that worked for my project
Delete /vendor folder
and execute composer install
then run project php artisan serve
In my case composer was not installed in that directory. So I run
composer install
then error resolved.
or you can try
composer update --no-scripts
cd bootstrap/cache/->rm -rf *.php
composer dump-autoload
I just fixed this problem (Different Case with same error),
The answer above I tried may not work because My case were different but produced the same error.
I think my vendor libraries were jumbled,
I get this error by:
1. Pull from remote git, master branch is codeigniter then I do composer update on master branch, I wanted to work on laravel branch then I checkout and do composer update so I get the error,
Fatal error: Class 'Illuminate\Foundation\Application' not found in
C:\cms\bootstrap\app.php on line 14
Solution:
I delete the project on local and do a clone again, after that I checkout to my laravel file work's branch and do composer update then it is fixed.
I had accidentally commented out:
require __DIR__.'/../bootstrap/autoload.php';
in
/public/index.php
When pasting in some debugging statements.
For latest laravel version also check your version because I was also
facing this error but after update latest php version, I got rid from
this error.
run composer require laravel/framework after composer install then php artisan key:generate its work for me in kali linux
I can't imagine that anyone else reading this is a stupid as I was but just in case...
I had accidentally removed "laravel/framework": "^5.6" from my composer.json when resolving merge conflicts.
please test below solution:
first open command prompt cmd ==> window+r and go to the location where laravel installed.
try composer require laravel/laravel
i was having same problem with this error.
It turn out my Kenel.php is having a wrong syntax when i try to comply with wrong php8 syntax
The line should be
protected $commands = [
//
];
instead of
protected array $commands = [
//
];
#kalhan-toress 's comment is what ACTUALLY WORKED FOR ME
remove /bootstrap/start.php,composer.lock, and the vendor and run composer install
In my case, the error was caused on initial deployment because I didn't have a .env file in that directory (because those don't belong on Github where the files were transferred from).
check your .env file i think you miss something. Maybe like this
if yes then need to add manually and composer update or install composer

Unable to update Laravel 4 with Composer (Update: bug?)

Today, I pulled down the laravel/laravel repository from Github. I then ran php composer.phar install (as I normally would on my system, with a command window in the project directory). However, when I ran php composer.phar update, I received this error:
Everything installed just fine, and Laravel works as it should.
Any ideas what could be causing this issue?
Edit 1
artisan exists in the root of the project, but it throws an exception when I attempt to run php artisan optimize:
Side Note 1
If I try the alternative method (quicker) of installing Laravel (php composer.phar create-project laravel/laravel), I get the following:
Edit 2
Upon installation, I also get the same error, where it claims it cannot find artisan. Therefore, the installation does not fully complete. I believe that it is stopping when it wants to compile classes (or something to that effect), and then write bootstrap/compiled.php. That file doesn't exist.
Here's the snap from the install:
Edit 3
It seems that Composer is looking for artisan in the drive root (C:\). Why is it doing this? Even if I specify -d on the update, it throws the error. (I picked this up from a hunch - simply copied artisan to the root of the drive and it found it - albeit, it obviously did not run...)
Solution Found:
Composer makes calls to php artisan <command> (as per the instruction in composer.json > scripts), but it does not see what directory it is running from (perhaps because it is an external command?).
So, I solved my initial problem by using an absolute path to artisan in composer.json.
Everything is working now. I just wish I knew how to get Composer to know that it is running from C:\LocalServer\lab\laravel, and not just C:\.
As i can see, your artisan file is missing. Can you post the exact steps on how you install it ?
Also, please follow http://laravel.com/docs/installation and http://niallobrien.me/2013/03/installing-and-updating-laravel-4/
I had this problem today too. My laravel folder inside the vendor was deleted after composer update. I ran composer install again and problem resolved.

Categories