Unable to read the "../.dev.env" environment file in Dotenv.php:symfony - php

I want To run a symfony project in my computer but I get all times errors , and now I get this error and i didn't find any solution for my problem
Problem Failed to parse output as xml: Error on line 2: Content is not
allowed in prolog.. Command C:\xampp\php\php.exe
C:\xampp\htdocs\buzzaka\bin\console list --format=xml Output
Fatal error: Uncaught
Symfony\Component\Dotenv\Exception\PathException: Unable to read the
"C:\xampp\htdocs\buzzaka\bin/../.dev.env" environment file. in
C:\xampp\htdocs\buzzaka\vendor\symfony\dotenv\Dotenv.php:466 Stack
trace:
0 C:\xampp\htdocs\buzzaka\vendor\symfony\dotenv\Dotenv.php(51): Symfony\Component\Dotenv\Dotenv->doLoad(false, Array)
1 C:\xampp\htdocs\buzzaka\bin\console(38): Symfony\Component\Dotenv\Dotenv->load('C:\xampp\htdocs...')
2 {main} thrown in C:\xampp\htdocs\buzzaka\vendor\symfony\dotenv\Dotenv.php on line 466

If u move your file from the folder where it was created symfony will keep looking for it on this folder, i've went on autoload_runtime and changed on $runtime variable where the project is, just worked for me, lets see on the last composer dump what just happens haha

The error is quite explicit, do you have a file C:\xampp\htdocs\buzzaka\bin/../.dev.env ?
Well, you need to create one. As announced a little while ago, Symfony will now require a .env file per environment. As you are running your command in the dev environment, you need to create a .dev.env file.

Related

OCR wrapper for php

I am using this for ocr. This is wrapper for Tesseract ocr(I previosly installed Tesseract itself).
At first i dowloaded it via composer and followed examples in repo and also several posts on SO itself. And all can show is in network tab failed to load response data.
My alternate approaches is that i tried downloading repo itself, then tried to call it from my index.php which for test purposes is situated in same folder where class TesseractOCR is. I tried with images in repo and also tried with black letters on white background images with simple text.
This SO post looks promising, but i'm unsure where OP's file with example code is residing...
use thiagoalessio\TesseractOCR\TesseractOCR;
//or//require "TesseractOCR.php";//if it's in the same dir as test.php
$content = new TesseractOCR('text.png');
$text = $content->run();
echo $text;
Did i miss something obvious? Any help is appreciated.
EDIT1: I tried using in win powershell cli. By putting text.png in directory where tesseract is installed, then calling shell with administrator privileges, subsequently typing in it tesseract text.png output which creates output.txt in same directory with recognized text from that image.
So tesseract its working, my implementation with php wrapper is not.
EDIT2:
Forgot to add, page itself shows:
This page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500
Not sure why it happens.
Edit3:
My code:
try{
//use thiagoalessio\TesseractOCR\TesseractOCR;
require "./vendor/thiagoalessio/tesseract_ocr/src/TesseractOCR.php";
echo $temp;//It's value is set in TesseractOCR.php
$content = new TesseractOCR('text1.png');
$text = $content->run();
echo $text;
}
catch(Exception $e) {
echo 'Message: ' .$e->getMessage();
}
Value set in $temp variable is visible through state file path, so why TesseractOCRclass itself isn't?
Edit4:
Even if i put absolute path to TesseractOCR.php which holds class, in include statement, it doesn't work.
It throws this error:
Fatal error: Uncaught Error: Class 'TesseractOCR' not found in C:\xampp\htdocs\myocr\index.php:10 Stack trace: #0 {main} thrown in C:\xampp\htdocs\myocr\index.php on line 10
This is TesseractOCR.//echoed text from file that holds TesseractOCR class.
Inclusion path:
include ("C:/xampp/htdocs/myocr/vendor/thiagoalessio/tesseract_ocr/src/TesseractOCR.php");
If i use(which is suggested in repo readme, use thiagoalessio\TesseractOCR\TesseractOCR;, then it throws:
Fatal error: Uncaught Error: Class 'thiagoalessio\TesseractOCR\TesseractOCR' not found in C:\xampp\htdocs\myocr\index.php:10 Stack trace: #0 {main} thrown in C:\xampp\htdocs\myocr\index.php on line 10
My question is: How it hits test message, but won't hit TesseractOCR class?
EDIT5:
If i require_once "./vendor/autoload.php"; , it throws:
Fatal error: Uncaught thiagoalessio\TesseractOCR\TesseractNotFoundException: Error! The command "tesseract" was not found. Make sure you have Tesseract OCR installed on your system: https://github.com/tesseract-ocr/tesseract The current $PATH is C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Users\Eddie\AppData\Local\Microsoft\WindowsApps;;C:\Users\Eddie\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Eddie\AppData\Roaming\npm;C:\Users\Eddie\AppData\Roaming\Composer\vendor\bin;C:\Program Files\heroku\bin in C:\xampp\htdocs\myocr\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php:48 Stack trace: #0 C:\xampp\htdocs\myocr\vendor\thiagoalessio\tesseract_ocr\src\TesseractOCR.php(26): thiagoalessio\TesseractOCR\FriendlyErrors::checkTesseractPresence('tesseract') #1 C:\xampp\ht in C:\xampp\htdocs\myocr\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php on line 48
Btw, i added its patch to env variable:
I solved it!. My problem occurs that i didn't know about autoloaders in php.
Link that helped me is this.
My project structure is this:
Created project folder myocr.
After previous, downloaded latest stable version of Tesseract and installed it.
Depending on your system, you may be required to add value to your system env variable. You need to do that here
then
then
then
I'm assuming it self explanatory with images provided.
Next is getting TesseractOCR via composer:
composer require thiagoalessio/tesseract_ocr
Finally, before using code sample in repo, you need to call autoloader.
Index.php:
require_once('./vendor/autoload.php');//<-This!
use thiagoalessio\TesseractOCR\TesseractOCR;
$content = new TesseractOCR('text1.png');
$text = $content->run();
echo $text;
This worked for me. Crucial thing to look after is directory structure.
localhost > myocr > index.php with its code, and after using composer you'll get vendor dir. and it's content. Image path in new TesseractOCR('text1.png'); is directory where both index.php and image are located.

Laravel 5.6: Uncaught ReflectionException: Class env does not exist

When running my Laravel 5.6 application on it's production server, I'm getting an error as follows both in the browser and in the console when trying to run artisan commands:
PHP Fatal error: Uncaught ReflectionException: Class env does not exist in /var/www/html/service.straightlinefernie.com/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php:767
Stack trace:
#0 /var/www/html/service.straightlinefernie.com/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php(767): ReflectionClass->__construct('env')
#1 /var/www/html/service.straightlinefernie.com/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php(646): Illuminate\Container\Container->build('env')
#2 /var/www/html/service.straightlinefernie.com/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php(601): Illuminate\Container\Container->resolve('env', Array)
#3 /var/www/html/service.straightlinefernie.com/dev/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(734): Illuminate\Container\Container->make('env', Array)
#4 /var/www/html/service.straightlinefernie.com/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php(1210): Illuminate\Foundation\Application->m in /var/www/html/service.straightlinefernie.com/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 767
The app runs fine on my development environment. I've combed my .env and config/ files for errors, and it all appears good.
I'm guessing there is something missing in my server set up, but
the main problem as I see it is that this error message is too generic and doesn't provide the information required to discover what specific file or error is actually making the boot process fail.
The stack trace is not even saved in the log file, and appears only in the console when I try to run artisan commands.
Does anyone know how to get a more detailed error message that can actually help me solve this error?
Perhaps there is a way to edit the file Illuminate/Container/Container.php so that it gives me more info?
Thanks
If composer dump-autoload -o and php artisan config:clear doesn't work then check your .env for potential errors like this:
KEY=THE VALUE
Should be
KEY="THE VALUE"
I faced this issue and found issue in config folder > constants file I was wrote "asset('/')" and "url()" function in config file, we can't write such functions in config.
Hope this answer will some one who stuck like this errors.

Error during composer update/install upon migrating to remote server

The error in question:
[RuntimeException]
Error Output: PHP Warning: require(/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php): failed to open stream: N
o such file or directory in /home/admin/web/"webpage"/public_html/test/vendor/composer/autoload_real.php on line 58
PHP Stack trace:
PHP 1. {main}() /home/admin/web/"webpage"/public_html/test/artisan:0
PHP 2. require() /home/admin/web/"webpage"/public_html/test/artisan:16
PHP 3. require() /home/admin/web/"webpage"/public_html/test/bootstrap/autoload.php:17
PHP 4. ComposerAutoloaderInit95cd02d44d232a8b8d6e5e52544d8647::getLoader() /home/admin/web/"webpage"/public_html/test/vendor
/autoload.php:7
PHP 5. composerRequire95cd02d44d232a8b8d6e5e52544d8647() /home/admin/web/"webpage"/public_html/test/vendor/composer/autoload
_real.php:49
PHP Fatal error: require(): Failed opening required '/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php' (includ
e_path='/home/admin/web/"webpage"/public_html/test/vendor/phpunit/php-text-template:/home/admin/web/"webpage"/pub
lic_html/test/vendor/phpunit/php-timer:.:/usr/share/pear:/usr/share/php') in /home/admin/web/"webpage"/public_html/test/vendor
/composer/autoload_real.php on line 58
PHP Stack trace:
PHP 1. {main}() /home/admin/web/"webpage"/public_html/test/artisan:0
PHP 2. require() /home/admin/web/"webpage"/public_html/test/artisan:16
PHP 3. require() /home/admin/web/"webpage"/public_html/test/bootstrap/autoload.php:17
PHP 4. ComposerAutoloaderInit95cd02d44d232a8b8d6e5e52544d8647::getLoader() /home/admin/web/"webpage"/public_html/test/vendor
/autoload.php:7
PHP 5. composerRequire95cd02d44d232a8b8d6e5e52544d8647() /home/admin/web/"webpage"/public_html/test/vendor/composer/autoload
_real.php:49
Background: Was developing locally, got to the point where I wanted to have a staging site. Set up the staging site on digital ocean (entOS 6.5 x64). I then cloned my git repo into my desired folder - configured vhosts DefaultDirectory to my public path.
A default installation works, composer update/install works. However, with my cloned repository I am getting said error. '/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php' is a file I made with some helper methods I could use in various controllers. It has not caused any problems locally. I can composer update/install locally, without any problems.
Any guidance would be greatly appreciated!
Are those literal quotation marks in your file path
/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php
Or are you just using that to indicate your website name normally goes there? If the former, I'd consider not doing that as it's pretty weird to have quotes in unix file names, and you may run into problems based on assumptions other people have made.
Regardless -- you have the information you need
[RuntimeException] Error Output: PHP Warning: require(/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php): failed to open stream: N o such file or directory in /home/admin/web/"webpage"/public_html/test/vendor/composer/autoload_real.php
PHP is telling you it tried to require in a specific file
/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php
but it could not find it ("failed to open stream"). This means either the file doesn't exist on the computer you're trying to load it from, or PHP can't see it for some reason (try dumping the results of is_readable('/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php'); to see if PHP thinks it can read the file or not.

Mirror API database access issue

I just installed the Google mirror API. I have everything setup except after I log in to the API, I get this error message:
Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\mirror-client.php on line 33
Fatal error: Uncaught exception 'Exception' with message 'Unable to open database: unable to open database file' in C:\xampp\htdocs\util.php:62 Stack trace: #0 C:\xampp\htdocs\util.php(62): SQLite3->__construct('/tmp/database.s...') #1 C:\xampp\htdocs\util.php(26): init_db() #2 C:\xampp\htdocs\oauth2callback.php(41): store_credentials('107736579479351...', '{"access_token"...') #3 {main} thrown in C:\xampp\htdocs\util.php on line 62
It seems that the API can't create the database or do I need to create it?
I tried making a folder and database as it is set up in the config.php file "tmp/database.sqlite" but no luck.
Any ideas?
I figured out that you had to make your own database for it to work.
It can mean that the directory/folder you placed the sqlite file in (and the file itself) does not have the correct permissions. You need to make sure both the folder and the file have read and write permissions. The xampp directory in my environment has read/write permissions. You might want to place your database there, at least for testing purposes.
Note: The /tmp directory as mentioned in "/tmp/database.sqlite" is a Linux/Mac directory. You may want to change the value of $sqlite_database in the config.php file to point to a file in a Windows directory.

Zend session_start gives Fatal error: Exception thrown without a stack frame in Unknown on line 0

When running a Zend application locally I get Fatal error: Exception thrown without a stack frame in Unknown on line 0, i traced that error to a line $startedCleanly = session_start();
I can't get through it, when I restart the server and reload the page I do not get the error, but on every other reload I get it, I looked into a php/tmp dir too see if there are any files, and as I see they aren't there. I think that session isn't written but when I try just a simple test.php file with session_start(); line, without zend framework, I see that there is a file created in that dir.
I really don't know where to go next.
Happens when your destructor or error handler throws an exception. That can happen for multiple reasons depending on your exact setup and method for session storage you're using. For example the session directory is not writeable or does not exist, database is not accessible or fields are invalid, redis does not respond, etc.
So, check your settings and look for something that would prevent saving the session data.
More elaborate description can be found here.
I know this post is old, but I've just figured out that I was getting "Fatal error: Exception thrown without a stack frame in Unknown on line 0" because my 'modified' and 'lifetime' columns were of type 'timestamp without time zone' when they should have been 'integer' (I'm using Postgres 9 BTW)
Hope this helps someone.
The problem could also be a disk full problem !!!

Categories