I have this laravel api hosted on a sharefd hosting siteground, i made some changes like changing the public folder to public html and update the storage filing so i can be able to run the laravel storage link commande bu i encountred this error while trying to access my temporary domain
FULL ERROR NAME
Carbon\Carbon::setLastErrors(): Argument #1 ($lastErrors) must be of type array, bool given, called in /home/customer/www/bassemb5.sg-host.com/vendor/nesbot/carbon/src/Carbon/Traits/Creator.php on line 98
and this is my index.php looks like
<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
$app->bind('path.public', fn() => base_path('/public_html'));
$kernel = $app->make(Kernel::class);
$response = $kernel->handle(
$request = Request::capture()
)->send();
$kernel->terminate($request, $response);
and this is the line i added and it was working perfectly
$app->bind('path.public', fn() => base_path('/public_html'));
Hi Also managing my old site.
You need to update your composer by using
composer update
And all work fine
We had exactly the same error (same file and line) than OP.
In our research it looks like it got broken after 2.57 (working), for us 2.58 was already failing and broke our pipeline, failing in the "composer install" phase with exactly same error.
As #tomexsans mentions it seems to be fixed in 2.62.1+. We upgraded to the latest available version today (2.64) and worked fine, getting the issue fixed.
--
TL;DR
composer update nesbot/carbon
should do the trick.
Also managing my old site on Siteground, customer contacted told me about 500 error.
When I looked at the Logs nothing is wrong.
When I turned on the app_debug we had the same error.
It does not happen on localhost because I have PHP 8.1 installed.
If you're using PHP 8.2 and this problem appears, you need to update your composer.lock to the latest carbon version
https://github.com/briannesbitt/Carbon/releases/tag/2.62.1
or just pull back your PHP version to 8.1
UPDATE: this error came from Siteground Auto Updating your PHP VERSION to 8.2
I have mine forced to PHP 8.1 yet they still Auto Managed it and upgraded the PHP Version to 8.2 without any notifications or advise
I had this issue a few days again
just type composer update on your terminal that will solve the issue.
Give this a vote afterward.
We used carbon in combination with aporat - store receipt validator.
Unfortunately we couldn't update the nesbot using composer, due hardlocked versions and nesbot being a dependency of another library.
Luckily when comparing the libraries Creator file we saw the hotfix in the latest version, by that time being:
https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Traits/Creator.php
We ended up fixing it with only updating that specific file, since only the setLastErrors() function was updated there.
I truly hope it helps someone.
If you can not change your PHP version to 8.1, you can update this line
File Path
./vendor/nesbot/carbon/src/Carbon/Traits/Creator.php
Line No:
928
Old Line
private static function setLastErrors(array $lastErrors)
New Line
private static function setLastErrors($lastErrors)
Related
i already upload files in the public folder to public_html, and others to laravel.
i changed index.php too.
but i get nothing ....
[
I get this...
Some one can help me?
Thanks
EDIT:
This is my index file, i think thats is good
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/
require __DIR__.'/../laravel/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
EDIT:
Now i have this locally in XAMPP
The question is quite old however others may find this answer useful. Basically what you have to do is to configure the App to work properly in the new environment.
Go to 000webhost cPanel > Settings > General > Reset website. You must make sure no other content is present in your site to prevent interference.
Archive your entire Laravel Project in ZIP format.
Upload the archive to 000webhost site to /public_html using File Manager.
Move all files/folders which are on the same level with package.json to /
Delete /public_html. You won't need it anymore.
Rename /public to /public_html
Go to /app/Providers/AppServiceProvider.php at register() method and append the following code inside it:
$this -> app -> bind('path.public', function()
{
return base_path('public_html');
});
Open /.env. Copy APP_KEY value without base64:
Go to /config/app.php, find 'key' and replace the line with the following code:
'key' => env('APP_KEY', base64_decode('%YOUR_COPIED_APPKEY%'));
If you have your project connected to a database, update the database credentials from /config/database.php. Lookup for mysql vector and update the database, username, password properly.
...And this should do the trick. If you have further questions, a tutorial has been written about the entire procedure here: https://www.000webhost.com/forum/t/deploy-laravel-project-into-000webhost-site/127323/
Hope this helps :)
WRITE YOUR index.php
$app->bind('path.public', function() {
return __DIR__ ;
});
I used to specify the app version inside composer.json until I read somewhere here in Stack Overflow that it was a bad practice. What is the standard file to specifying the app version on a PHP Laravel application? (i.e: in .NET that'd be the config file, on iOS it'd be the info.plist, on Android it'd be the Manifest, etc...)
config/app.php is definitely the place for such information.
Why ? Because the configuration files are (or should be) included in your versioning flow and they (should) contain non-sensitive information about your application. The perfect place for a simple version indicator.
under the name index of the array, you could set a version index like this
/*
|--------------------------------------------------------------------------
| Application Version
|--------------------------------------------------------------------------
|
| This value is the version of your application. This value is used when
| the framework needs to place the application's version in a notification
| or any other location as required by the application or its packages.
*/
'version' => '1.0.0',
#delatbabel
has a great start for version
config/app.php
'version' => env('APP_VERSION', '1.0.0'),
for config/bugsnag:
'app_version' => env('APP_VERSION', '1.0.0'),
then you can simply get your version with:
config('app.version')
Docker
now in docker you could set a default version on build:
ENV APP_VERSION=1.0.0
for example with circle CI you can add your build number:
ARG BUILD_NR
ENV APP_VERSION=1.0.$BUILD_NR
Now in your config.yml, you can add following job commando:
deliver-prod:
machine: true
steps:
- checkout
- docker build --build-arg BUILD_NR=$CIRCLE_BUILD_NUM .
I normally set it in my .env file and then pick that up in a config.
e.g. .env says:
APP_VERSION=2.1
config/app.php says:
'version' => env('APP_VERSION', '0.0.1-alpha'),
My approch for now: GitLab pipeline writes the "version.php" file after every successful build. The file has the following content:
<?php const VERSION = '1.2.3';
In the "config/app.php" I include the file
require_once __DIR__ . '/../version.php';
...
'version' => VERSION,
...
The version can be queried as follows (e.g. as a route):
Route::get('api/version', function () {
return ["version" => config('app.version')];
})
->name('version');
I have a newbie question in laravel. I'm trying to query a DB. I have already modified the config to include the necessary credentials for my DB. Now, when i try to query my DB like this:
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function()
{
$topPages = DB::table('webmasters') -> get();
return $topPages;
});
I get: Fatal error:
Class 'Route' not found in /.../.../.../dashboard/app/routes.php on
line 13.
I have followed laracast video for accessing a database to the letter, can someone pls tell me what i'm missing or doing wrong here?
Thanks in advance.
maybe the route cache issue run command
php artisan route:cache
Possible Solutions:
Update the app by composer (composer update)
Check for file permission
How could i link Laravel log files to PaperTrial ?
According to this article :
http://mattstauffer.co/blog/laravel-forge-logging-with-papertrail#step-4-add-a-syslog-handler
I followed steps and reached to step 4 putting Syslog Monolog handler in the /app/route.php file ,went to PaperTrial dashboard but i didn't see any output.
Any help ? thanks.
For Laravel 5.1 after setting up the forge, you should add to bootstrap/app.php file the following code just before the return of the $app variable
$app->configureMonologUsing(function($monolog){
$monolog->pushHandler(new Monolog\Handler\SyslogHandler('papertrail'));
});
return $app;
The parameter (in this case 'papertrail') can be whatever you want to, this name will show on the papertail's event screen.
I have it working using the standard logging facility instead of Monolog. This way there is nothing extra to install. Just add this to rsyslogd's conf:
### Laravel Log
$InputFileName /path/to/vhost/dir/app/storage/logs/laravel.log
$InputFileTag laravel-errors-domain.com:
$InputFileStateFile state-laravel-errors-domain.com
$InputFileSeverity error
$InputRunFileMonitor
And make sure that this log gets included in the send action, if you are not sending everything.
Then issue
service rsyslog restart
From my experience using Laravel 5.2.* with Forge, Step 4 from that article is not necessary anymore. All you have to do after Step 3 is set your Environment .env settings in Forge to APP_LOG=syslog for each site you want to use with papertrail.
However, this means that Laravel will not log to laravel.log anymore in this environment. But, in other environments (e.g. dev environment) you could of course continue logging to laravel.log by simply not making any changes to the .env file there.
I have created a Google AppEngine and loaded the Drupal extension http://blog.boombatower.com/drupal-integration-module-google-app-engine
This loaded and ran correctly.
I then added the rest of an existing Drupal site, and added some extra entries in the settings.php file to handle additional facilities, including memcache and FB
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
// The 'cache_form' bin must be assigned no non-volatile storage.
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['memcache_key_prefix'] = 'something_unique';
require_once "sites/all/libraries/purl-master/src/Purl.php";
include "sites/all/modules/fb/fb_url_rewrite.inc";
include "sites/all/modules/fb/fb_settings.inc";
When I load the site to the AppEngine and then view I get errors regarding files not found. These are image files which have a space character in the name. The referencing URL looks correct. Other image files without a space in the name work correctly.
17:32:41.844 Static file referenced by handler not found: __static__/sites/default/files/images/frontpage/Titan%20#%20Kiva%20Beach.jpg
I will move this and my other files to Cloud storage after I have the basics running.
When I check for instances of the AppEngine none are showing. Yet the site loads and runs / partially, I have issues with responsive menus which is preventing me access the admin and other pages
Warning: Invalid argument supplied for foreach() in responsive_menus_glob_recursive() (line 491 of /base/data/home/apps/s~app-laketahoe-com/1.374191105859253183/sites/all/modules/responsive_menus/responsive_menus.module).
Not sure if this is related.
I wanted to SSH into the AppEngine to look at the file system but can't find it listed in the instances. I had added the Compute Engine at a later date but it should be independant of the App Engine.
greg#ubuntu:~$ gcutil listinstances
+------------------+---------------+---------+--------------+---------------+
| name | zone | status | network-ip | external-ip |
+------------------+---------------+---------+--------------+---------------+
| vm-laketahoe-com | us-central1-b | RUNNING | 10.240.36.10 | 23.251.150.90 |
+------------------+---------------+---------+--------------+---------------+
Thanks in advance
I don't believe filenames with spaces in them are supported at all.
Also there is a bug with glob() calls not working which might be the Warning you're seeing.
Lastly you cannot SSH into app engine. The admin console for your app engine apps is at https://appengine.google.com/