As I am using the local hosting of MAMPbut " There has been a critical error on this website" this is error is coming. What should I do?
Diagnostic steps worth giving a shot, follow from top to bottom order;
Is MAMP really running with Web server (and additionally the database server)?
Do you see the default MAMP index/home screen?
Put a simple HELLO WORLD HTML document to your project root and check if you can see it on browser
Put a simple HELLO WORLD PHP script to your project root and check if you can see it on browser
At this point, if everything above went well, it is definitely an issue with your actual PHP script, check the PHP error log file
Put an INFO.PHP PHP script at your project root and check you have all the required extensions available for your PHP project
Check if database connection is working (if required)
At this point, I cannot imagine what else would go wrong, try PHP debugger (xDebug needs to be installed with MAMP and your PHP editor may need a configuration for this) with break points and step into each line of your PHP code with debugger.
Before you continue to read - the issue has been fixed
Well... this is kinda weird.
I'm working on a web app for some friends. I have a working version uploaded to their hosting, and, suddenly, it stopped working a couple of days ago.
I haven't added anything or changed anything on the server. There is no error, simply the app stopped loading and a blank html page is loaded instead.
I've traced the problem until /vendor/composer/autoload_real.php file.
In the end of the static class inside this file, there is a loop where several other files are being included (actually requested), I've checked that when it tries to request /vendor/laravel/framework/src/Illuminate/Foundation/helpers.php, the system stops. Obviously, I've checked that the file is there, and it isn't been touched.
Well, I'm positive I've didn't changed anything on this part of the app (it's core framework, and I usually don't mess up inside), but just of a sudden it stopped working.
The working copy on my computer just works fine. I've uploaded my copy of helpers.php, but nothing changed.
Anyone had experienced similar issues recently? Anyone has any idea about how to fix it?
EDIT: It's been several days since I could check on this for the last time.
Now I've been tracing raw php execution on /vendor/laravel/framework/src/Illuminate/Foundation/helpers.php file. This is, I've started echoing messages and trying to execute just this file, to see where code execution is stopped.
I know this is very crappy debugging, but I haven't access to apache nor I can restart it, and it seems there is no easy way to get an error code without this.
So patiently trying I've reached two points where execution stops on this file:
Creation of factory method
if (! function_exists('factory')) {
/**
* Create a model factory builder for a given class, name, and amount.
*
* #param dynamic class|class,name|class,amount|class,name,amount
* #return \Illuminate\Database\Eloquent\FactoryBuilder
*/
function factory()
{
$factory = app(EloquentFactory::class);
$arguments = func_get_args();
if (isset($arguments[1]) && is_string($arguments[1])) {
return $factory->of($arguments[0], $arguments[1])->times($arguments[2] ?? null);
} elseif (isset($arguments[1])) {
return $factory->of($arguments[0])->times($arguments[1]);
}
return $factory->of($arguments[0]);
}
}
and creation of mix method
if (! function_exists('mix')) {
/**
* Get the path to a versioned Mix file.
*
* #param string $path
* #param string $manifestDirectory
* #return \Illuminate\Support\HtmlString|string
*
* #throws \Exception
*/
function mix($path, $manifestDirectory = '')
{
return app(Mix::class)(...func_get_args());
}
}
In both cases func_get_args is involved... I haven't a specific error, but I have the tingling that the problem is related somewhat to the fact that this function isn't returning anything.
EDIT2: Ok, I tried php artisan and composer commands suggested on answers to no success. The issue is still there.
I've also deleted the logs and checked that no new log was created while trying to load the site.
I've tried a clean laravel install from scriptaculous on a new directory (I've done this when I first uploaded the site, it worked perfectly for several months) and this new install doesn't reach the front page neither. A blank page (on Firefox) or a 500 error (on Chrome) is shown instead.
I forgot to mention an important data. My app is sharing space with a wordpress instance. The wordpress is installed on public_html, and my site on public_html/mySiteDirectory. This hasn't supposed any problem so far more than make me tweak lightly .htaccess file to make routing work fine.
There is also a phpbb forum sharing space on it's own directory inside public_html.
I wonder if any of those could have somewhat been upgraded and produced this strange outcome.
Also... laravel app_debug is enabled on .env file since the beginning, but never showed anything. This seems to be something that fails before laravel framework is fully loaded.
EDIT 3: IT'S FIXED.
Well... first of all, let me thank you all for your help. Actually there wasn't one answer that fixed the problem, but many of you suggested to use phpInfo() to check php version which ultimately led to the true problem.
Yes... surprisingly, although php -v on terminal showed php 7.2 running on server, and cpanel php management tools showed also php 7.2 installed and running, when I used phpInfo(); php 5.6 was showed on the response.
I used the own cpanel tools to make an upgrade/downgrade to 7.3 and again to 7.2 and et voilá phpInfo(); shows 7.2 and the page is again up and running.
I'll try to share the reward between several answers (don't know if something like that is even possible), and will +1 every answer suggesting phpInfo(); as it showed as the key to fixing this problem.
If I cannot share the reward I'll accept as final answer the one from Don't Panic, as it was the one that convinced me that there was a problem with php versions.
If you look at the code in the functions you have traced the problem to, both contain interesting or less-common PHP features:
factory() includes ??, the null coalescing operator. This was introduced in PHP 7.0.
I see in a comment you added to another answer that you are using PHP 7.2. This question describes Laravel failing in factory(), because even after upgrading to PHP 7.2, and phpinfo() showing 7.2, Apache was still using PHP 5.6. This seems unlikely, but when all else fails ... ?
mix() includes ..., the spread or splat operator. This was introduced in PHP 5.6, but there are reports of it failing in Laravel with 7.x due (AFAICT) due to mismatches between the PHP versions Apache and the CLI are using.
Considering you mentioned you uploaded the code from your local machine (rather than using php composer install), and that CPanel tends to update PHP automatically and silently, this seems like a possibility - there are 4 PHP versions in play (CLI/web on your machine, and CLI/web on server), and they all need to be in sync.
As a side note, as you've already discovered you are really working blind without the logs. Either the PHP and/or Apache logs will give you more info, typically describing exactly the problem, and save you having to manually trace things as you've been doing. If those logs aren't showing anything, maybe PHP isn't configured to log errors - try enabling that.
It probably depends on your CPanel version and config, but standard locations for your logfiles are typically:
Apache access log: /usr/local/apache/domlogs/<your-username>/
Apache error log: /usr/local/apache/logs/error_log
PHP error log: /home/<your-username>/public_html/error_log
Start wtih composer dumpautoload. Then run php artisan optimize:clear. Re-upload the whole site and you should be good to go. I have experienced a very similar issue. Do you run a pipeline on the server or are you just FTP-ing the site up? Are you able to run composer on the server and the same for artisan? If you can, you need to those commands there are as your cache is often based on your host computer drives and will fail in prod.
Simply replacing the file might not be helpful. Try enabling the error log or check if you are able to reach this file bootstrap/app.php. If yes it means there is no problem in the composer. Try checking the version of PHP installed and if it is compatible with your Laravel. Try checking PHP Error Log. It might be helpful.
Ok I should mention a few things
1: Go to storage/logs directory and delete all *.log files then you refresh the web page and you'll check out to see for any log file if there is no log file it means it's related to server configuration and etc. if there is a log file you read it and you post it in here
2: Did you pull the code on cpanel by console command using version control system like git or svn or you just uploaded it in a classic way, if you indeed pulled it with VCS you may did a composer update instead of composer install which will updates all packages as possible as defined in composer.json file and you may have got a higher version of vendor than your local and something may broke in there.
3: You may have a different php version on server vs your local which many times casing real problems.
I can't tell for sure until you post your log file here
So here is what i would have done.
If it is possible simply turn0on debugging, this will show you the error in the web browser itself (you can do that from .env file)
You can also read the laravel log file for errors as mentioned earlier.
If you do not want to do this, run the following commands
PHP artisan cache:clear
PHP artisan route:cache
PHP artisan config:cache
PHP artisan clear-compiled
PHP artisan optimize
If you could share more details that would help...
Have you checked permissions and ownership for storage and bootstrap/cache folder?
these permissions need to be set for the app to work
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
I tried everything and nothing worked. The best solution for me was that I deleted cpanel files and reuploaded all the codes.
In a Vagrant Homestead environment (in Windows via VMware) I get the bare error 500 with some errors (e.g., forgotten "use") but normal Laravel debug error page with others (e.g., failing to define a route properly or failing to pass a variable to a blade template).
I have tried every solution I've found here and in searching, specifically:
Reset permissions of storage dir (changed inside the VM and in Windows via git bash)
Reset permissions of bootstrap/cache dir (changed inside the VM and in Windows via git bash)
Cleared various cache directories
Checked Laravel log (nothing in it about the failed event at all - which seems very odd)
Checked nginx log (nothing in it about the failed event at all - which seems very odd)
Checked FPM log (nothing in it about the failed event at all)
Tried inserting my own exception code, per some people's posts, it never is executed/shown
Tried inserting old error_reporting(E_ALL); ini_set("display_errors", 1); include("file_with_errors.php"); in a few different places per other posts -- nothing.
Tried resetting the encryption key since someone said that might be an issue (why I don't know) -- nothing
Tried reverting back to a backup of a week ago to undo symphony/etc. upgrades -- nothing
Tried composer update -- nothing
Tried php artisan optimize -- nothing
My APP_DEBUG setting is right (and again working appropriately on many errors just not certain ones, like missing "use")
My project has ground to a halt because I can't debug even basic issues, and I'm out of ideas for what to try.
Any help greatly appreciated. I am stuck until I resolve this.
I have set up SonarQube server on my local system and run sonar runner. it will run good with .html file but when i am trying to run with php file, it failed and showing error like:
java illegal language exception blame sample.php file.
I installed all plugin as below.
git
java
javascript
web
php
c#
but it is not working.
You get this blame error because you are trying to analyze a set of files on which you have uncommitted changes.
To fix this:
Either you make sure that you a running an analysis on source code that has been freshly checked out from your version control system (and not changed since then-
Or you tell SonarQube to not try to get SCM information
You will find this in the "Administration > Configuration > SCM" settings page: it is called "Disable the SCM Sensor"
One more possibility to end up with this error "java illegal language exception blame file-name file" is that your repository could have been shallow cloned with depth=1.
In my case, we configured our jenkins to do a shallow clone with depth = 1 and this error came up. When I changed the depth = 2 and re ran the jenkins job, sonar:sonar worked fine and results are pushed to the sonar server.
Look at the field "Shallow clone depth" in the attached image.
Hope this helps.
I've copied a drupal6 site from a production server onto a dev server and have started trying to get it up and running and most of it runs ok except page variant.
On the live site the page variant shows on, on the dev site I can select the "Content" menu item and see all content that is supposed to be showing in the appropriate area however when It try to view on the front end on dev it shows the page wrapper but the main content area is blank.
When I click on the "Preview" menu item in the page variant admin the page doesn't display, however selecting this on the live server shows it fine.
It feels like a permissions / setting issue to me but so far I've not been able to figure it out. Any ideas?
This was a "Call-time pass-by-reference" issue and was caused by different PHP versions on live & dev. PHP 5.3 seems to allow the call allowed this call but gave a deprecation warning but the new dev server is on an updated version of PHP which doesn't allow this anymore (although it wasn't giving any errors either) so I had to make the following change (and will likely have several similar ones to do before I'm finished)
Had to update a function template_preprocess_panels_pane in in panels.module from
function template_preprocess_panels_pane($vars)
to
function template_preprocess_panels_pane(&$vars) {
as described in comment 21 on https://drupal.org/comment/6820396#comment-6820396
These was also a suggestion that you could update a php.ini value to allow call-time pass by reference (change allow_call_time_pass_reference = Off to allow_call_time_pass_reference = On in php.ini) but updating the code where necessary feels a better way to go.