Im using Laravel 8, codes works perfectly before in both dev and prod server before. but when i move to PHP8, it still works in Dev server, but got an error in my production environment with this message
TypeError
Dompdf\FrameReflower\Text::layout_line(): Argument #1 ($block) must be of type Dompdf\FrameDecorator\Block, null given, called in /home/aliseafo/ali/vendor/dompdf/dompdf/src/FrameReflower/Text.php on line 399
below is the sample code, even with this simple codes, it still got the error
<!doctype html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<html lang="en">
<head>
<title>Invoice - 1</title>
</head>
<body>
<main>
<div>
<h1 align="center">COMMERCIAL INVOICE</h1>
</div>
</main>
</body>
</html>
latest config:
Development PHP 8.1.6, Laravel 8.83, Laravel dompdf 2.0
Production PHP 8.1.8, Laravel 8.83, Laravel dompdf 2.0
but still got that error.
anyone experiencing this before, or any clue why and how?
thanks for any ideas
Did this attempt, but still got error:
already tried
php artisan cache:clear; php artisan config:cache
reinstall laravel dompdf both in dev or prod composer update
recopy all files from dev to prod directly
php-mbstring enabled already
charset=utf-8 already added in the templates
Update 1.
when im switched it back to PHP7.4, nothing changed with the code, and it can print the pdf file successfully. so i think there is something problem with between my php8.1 installation or the compatibility of laravel-dompdf with php8.1
Related
I am in the middle of creating a Laravel website, and have tested everything locally up to now and it has been working fine. I have set up a web server on a vps and have added the website to test that it the server is working. Everything in my public folder is not being picked up by the Laravel helper functions such as 'Mix' and 'Asset'.
This is how I would usually reference files locally, but for it to work on the server, I have to type the file path.
<!-- Styles -->
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
{{-- <link rel="stylesheet" href="/public/css/app.css"> --}}
<!-- Scripts -->
<script src="{{ asset('js/navController.js') }}" defer></script>
{{-- <script src="/public/js/navController.js" defer></script> --}}
When I open up the console in my browser, it shows this error code.
GET http://domain.name/js/navController.js net::ERR_ABORTED 404 (Not Found)
GET http://domain.name/css/app.css net::ERR_ABORTED 404 (Not Found)
Using
Ubuntu Server 21.04
Laravel 8
LAMP (MySql)
If /public appears in your URI, your site is misconfigured. The public/ dir should be the DocumentRoot, so that / in your browser shows the public/index.php file.
Here's an example of how to configure your document root in both Apache and nginx.
Lastly, a warning - serving your site out of the project root (as you are now) instead of public/ is a security risk and you shouldn't do that.
I have been able to deploy Laravel projects successfuly in the past.
For the first time I am using Laravel 8 with Jetstream and Livewire. Laravel is now using Fortify for login and registration auth.
My local server works perfect, no issues. After deploying the project to a Hostgator shared hosting account, my homepage loads correctly and reads and outputs data from my DB correctly.
However, when I try to access
mydomain.com/login/ or mydomain.com/login
or
mydomain.com/register/ or mydomain.com/register
I get a 500 error. Below at the end of this question I am pasting the error log.
I have done the following:
Updated composer version
npm rebuild
npm install
I tried both: npm run dev and npm run production and re-uploaded everything in each scenario.
I have pointed public/index.php path to the correct app folder to read the autoload.php and bootstrap/app.php files.
I have chmod all folders and subfolders to 755 and all files to 644
I find it really strange that my homepage loads flawless and brings data from DB just fine, therefore I know that my .env file has the correct db connection credentials. Only the login and registration will throw a 500 error.
My env file:
APP_NAME=NameOfApp
APP_ENV=production
APP_KEY=base64:KeyGeneratedWhenProjectCreated
APP_DEBUG=false
APP_URL=http://domain
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=db_works_good
DB_USERNAME=username_works_good
DB_PASSWORD=passwordWorksGood
Here is the laravel.log (shortened to what seems important):
[2020-11-30 20:25:34] production.ERROR: The Mix manifest does not exist. (View: /domain_root_path/app/resources/views/layouts/guest.blade.php) (View: /domain_root_path/app/resources/views/layouts/guest.blade.php) {"exception":"[object] (ErrorException(code: 0): The Mix manifest does not exist. (View: /domain_root_path/app/resources/views/layouts/guest.blade.php) (View: /domain_root_path/app/resources/views/layouts/guest.blade.php) at /domain_root_path/app/vendor/laravel/framework/src/Illuminate/Foundation/Mix.php:46)
[stacktrace]
#0 /domain_root_path/app/vendor/livewire/livewire/src/CompilerEngine.php(38): Illuminate\\View\\Engines\\CompilerEngine->handleViewException(Object(ErrorException), 0)
#1 /domain_root_path/app/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(60): Livewire\\CompilerEngine->handleViewException(Object(ErrorException), 0)
#2 /domain_root_path/app/vendor/livewire/livewire/src/LivewireViewCompilerEngine.php(32): Illuminate\\View\\Engines\\PhpEngine->evaluatePath('/home2/usr2...', Array)
...................
#52 /domain_root_path/public_html/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#53 {main}
[previous exception] [object] (Exception(code: 0): The Mix manifest does not exist. at /domain_root_path/app/vendor/laravel/framework/src/Illuminate/Foundation/Mix.php:46)
[stacktrace]
#0 /domain_root_path/app/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(506): Illuminate\\Foundation\\Mix->__invoke('/css/app.css')
#1 /domain_root_path/app/storage/framework/views/f25b68bee7f180a7da8624828693071be98325dc.php(14): mix('css/app.css')
#2 /domain_root_path/app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(107): require('/home2/usr2...')
............................................
#66 {main}
THE STRUCTURE OF FILES:
root has two folders:
app (has all files except public folder)
public_html : has all public content including index.php
My index.php (inside public) has the following paths:
require __DIR__.'/../app/vendor/autoload.php';
$app = require_once __DIR__.'/../app/bootstrap/app.php';
GUEST.BLADE.PHP looks like this:
(please note that this file was auto-generated by Laravel and I have not touched it)
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght#400;600;700&display=swap">
<!-- Styles -->
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine#v2.7.3/dist/alpine.js" defer></script>
</head>
<body>
<div class="font-sans text-gray-900 antialiased">
{{ $slot }}
</div>
</body>
</html>
/public/mix-manifest.json:
{
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css"
}
If you read below the error there is a hint about the solution :
Error's screenshot with a hint
You missed npm install && npm run dev
I replaced
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
with
<link rel="stylesheet" href="/css/app.css/">
and it works now.
The error happens because of two reasons:
you have to run npm install && npm run dev
if npm run dev command occurs error, please upgrade your node.js version to latest.
I am developing a Magento 2.3 site which was working but has stopped. When I try to get a page up, I get a blank screen. Although it looks empty, it actually contains a little content:
<!doctype html>
<html lang="en">
<head >
<meta charset="utf-8"/>
<meta name="description" content="Blah Blah"/>
<meta name="keywords" content="More blah blah"/>
<meta name="robots" content="INDEX,FOLLOW"/>
<title></title>
<link rel="icon" type="image/x-icon" href="http://www.magento2.domain/pub/media/favicon/stores/1/3-ladies-bg.jpg" />
<link rel="shortcut icon" type="image/x-icon" href="http://www.magento2.domain/pub/media/favicon/stores/1/3-ladies-bg.jpg" />
<link href='https://fonts.googleapis.com/css?family=Prosto+One' rel='stylesheet' type='text/css' />
<!--xxxabb2c66c7681e8f658-->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxx-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-131267613-1');
</script> </head>
<body data-container="body" data-mage-init='{"loaderAjax": {}, "loader": { "icon": "http://www.magento2.domain/pub/static/version1551796553/frontend/_view/en_GB/images/loader-2.gif"}}' class="cms-index-index page-layout-1column">
</body>
</html>
If I look in the system log, I see the following errors:
[2019-04-30 21:24:48] main.INFO: Broken reference: the 'theme.active.editor' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2019-04-30 21:24:48] main.INFO: Broken reference: the 'logger' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
I've enabled error logging but I get nothing. Can anyone help?
Alternatively, can somebody point me to a good map (or similar) of how magento 2 builds a page so I can try and track down the error.
I have tracked down the issue to a problem with pub/generated/metadata/global.php. Even regenerating it causes the same problem. If I delete the file everything seems to work ok. I confess to not understanding why!
I now avoid this by not running bin/magento setup:di:compile. I simply run php bin/magento setup:static-content:deploy.
I think this error is due to a broken reference in some XML file. You have not mentioned in which page you are getting this error. But you can trace it as below:
First of all, rename your default.xml from below path:
app/design/frontend/Vendor/Theme_name/Magento_Theme/layout/default.xml
Flush all the cache and check(php bin/magento cache:flush)
If you don't find anything then rename your page(homepage, listing, detail page, etc) related file.
For example, if you are getting this error on the homepage then rename cms_index_index.xml.It can reside in your theme or any custom extension.
Hopefully, this information can help you with the issue.
remove everything under generated folder except .htaccess file
I am using Magento 2.3.2 version. In production mode generating generated directory using setup:di:compile is working fine. However, in developer mode doing same is making all pages on frontend blank but not empty (content inside body tag is empty) so I deleted the generated folder and let it be created automatically as I access the site pages. Doing this resolved the issue for me.
Just go to Magento directory and then delete file generated by di:compile is path :-
magento\generated\metadata\global.php delete this file then after refersh your page.
This is temporary solution for this error in local server.
This question already has an answer here:
laravel new command with older version
(1 answer)
Closed 6 years ago.
c:\xampp\htdocs>laravel new --5.2 MyNewProj
Crafting application...
[GuzzleHttp\Exception\ClientException]
Client error: 'GET http://cabinet.laravel.com/latest-52.zip' resulted in a '404 Not Found' response:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="robots" content="noindex,nofollow (truncated...)
new [--dev] [--5.2] [--] [<name>]
While executing the laravel installer command I get this error.
I want to install laravel using the installer only.
So how can I resolve this error?
Looks like a bug at laravel side, see here Not found error:
http://cabinet.laravel.com/latest-52.zip
See this post, it is a duplicate of this post:
laravel new command with older version
I am developing a Web Application. I am using Laravel 5.3. I also want to use SASS. This is my first time of using SASS. I learned from this tutorial- http://blog.teamtreehouse.com/the-absolute-beginners-guide-to-sass. Now I am trying to integrate SASS with Laravel. I just started building project. So I decided to use this one - https://github.com/panique/laravel-sass.
I included this in composer.json
"require-dev": {
"panique/laravel-sass": "1.0"
}
I added this line in public/index.php
SassCompiler::run("scss/", "css/");
So my index.php in public folder look like this
Then I run "update composer" command in terminal. Installation worked well in terminal.
So now I need to try on SASS and make sure it is working or not.
So I created two file in public folder.
public/css/style.css
and
public/scss/style.scss
Then I created a view, hello.blade.php. This is the html.
<!DOCTYPE html>
<html>
<head>
<title>SASS</title>
<link rel="stylesheet" type="text/css" href="{{ url('css/style.css') }}">
</head>
<body>
<h1 class="heading">Let's sass. Just change color.</h1>
</body>
</html>
Then I added this lines in public/scss/style.scss
$red: #FF4848
.heading
color:$red
Then I configure Laravel route like this.
Route::get('hello', function () {
return View('hello');
});
When I access the URL from browser, it is giving me this error.
Fatal error: Uncaught Exception: parse error: failed at $color : red
line: 1 in
C:\xampp\htdocs\whatsuppathein\vendor\leafo\scssphp\scss.inc.php:4108
Stack trace: #0
C:\xampp\htdocs\whatsuppathein\vendor\leafo\scssphp\scss.inc.php(2761):
scss_parser->throwParseError() #1
C:\xampp\htdocs\whatsuppathein\vendor\leafo\scssphp\scss.inc.php(121):
scss_parser->parse('$color : red\r\n\r...') #2
C:\xampp\htdocs\whatsuppathein\vendor\panique\laravel-sass\sass-compiler.php(53):
scssc->compile('$color : red\r\n\r...') #3
C:\xampp\htdocs\whatsuppathein\public\index.php(50):
SassCompiler::run('scss/', 'css/') #4 {main} thrown in
C:\xampp\htdocs\whatsuppathein\vendor\leafo\scssphp\scss.inc.php on
line 4108
What is wrong with my code?
When I replace this line
SassCompiler::run("scss/", "css/");
with this
SassCompiler::run("public/scss/", "public/css/");
in public/index.php, it is not throwing error. But not changing any CSS. Not changing the font color.
Laravel uses gulp to transpile dependencies and it comes built it when you do npm install from your project direcftory.
Open up your resources/scss/app.scss file and you can perform #import statments to your own files.
The gulp.js file in your project's root directory contains the sass transpiling.