Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ozan's avatar

@JulienTant Why would you do that %99 percent of developers know English and as you know programming languages are based on English. We echo something, print something...

1 like
jasteralan's avatar

I want to upload a image (uploaded from front-end form)

I had tried this :

public function uploadToS3(UploadedFile $image) {
    Storage::driver('s3')->put($path, $imageFileContent, 'public');
}

The question is : I can't find a elegant way to fetch the image file ( $imageFileContent ) . Either it seems I can't move a file to s3 like this Storage::driver('s3')->put($image->getRealPath(), $destination)

Any advice? Thank you :)

nolros's avatar

Jeff there seems to be a problem with view related Service Providers on a fresh install of L5. Did something change in the past week or so as it was and is working on an L5 build from a week ago.

https://laracasts.com/discuss/channels/general-discussion/l5-fresh-serviceprovider-not-working

EDIT

 1. had to add boot() method to my SP
2. load View::composer with the Facade to get it to work.
3. Once it was working I once again ran clear compiled 
4. then removed all the boot code and went back to above and it works fine, which leads me to believe that the clear compiled needs to run on a working version of fresh version of L5 as it won't clear until the app runs once fine. weird
konomae's avatar

Hi,

I'm trying to use laravel-debugbar only local environment.

I want to add 'Debugbar' => 'Barryvdh\Debugbar\Facade', to app.aliases config for only local env.

I found a solution, but I don't know whether it is right way.

if ($this->app->environment() === 'local')
{
    $this->app->register('Barryvdh\Debugbar\ServiceProvider');
    AliasLoader::getInstance(['Debugbar' => 'Barryvdh\Debugbar\Facade']); //->register();
}
1 like
lihaibh's avatar

@mattstauffer ive read your post from here: http://mattstauffer.co/blog/upgrading-from-laravel-4-to-laravel-5 regarding the upgrading process. there is a part when you open a brand new branch for your laravel-5 application, what shall i do after finish transferring all the files from my backup to that branch (migrations, models etc..) and commit everything should i merge this branch to master and push it?

Because if i'll merge i think what happened is that i will have file duplicates for example the migration files in laravel 4 existing in the folder: app/database/migrations while in laravel 5: database/migrations.

Thank you for your help i love this community!

mattstauffer--personal's avatar

@lihaibh Sorry, I didn't get notified about your response!

If you take a little closer look at the blog post, it actually recommends you move your old files in the new locations--and it gives you specific directions on which of the new migrations you should keep around.

For example, you will be moving all of your files from app/database/migrations into the new database/migrations, and probably deleting one or more of the new migration files.

I hope this helps!

lihaibh's avatar

@mattstauffer thank you for your reply, however in your guide you told to first remove all the files and begin installing laravel 5 from scratch and transfer all the files to the right place, than you should 'git squash' all your commits into one.

Will git be smart enough to know ok i know files that was existing in 'app/database/migrations' now existing in 'database/migrations'?

Thank you.

mattstauffer--personal's avatar

@lihaib No. Git will not do the work for you.

That's why I said: You need to read the directions in the post, where it step-by-step tells you where to move them.

So, in your example, look here, where it tells you to move all code in app/database into database.

Screen cap from blog post

lihaibh's avatar

@mattstauffer as i understood, correct me if im wrong, you copy the files from your previous working directory to your new one (in which you create a fresh new laravel 5 application). Though you need first to clone your entire repository and than open branch for your new l5 application.

So i have a master branch with my current l4 app from my repository, i open new branch, remove everything, clone l5 base files, copy the files from MY PREVIOUS WORKING DIRECTORY (its not like i change the file path - because in the previous step i removed all my files and commited) to the current directory and git squash all the commits, will this be 'enough' so i will not loose any of my l4 files change history? I hope my question was cleaner.

And thank you for your answers :).

mattstauffer--personal's avatar

@lihaibh If you do what you just said, and squash the commits, Git should see them as moved rather than deleted and re-added. They have for me. Try it out and see what happens. :)

1 like
vincej's avatar

I've watched Jeffrey's lesson on environment configuration, read the L5 docs and Matt Staufers blog piece and I need to ask, what might be an obvious question, but yet is not answered by any of these resources:

  1. in config/database.php I have:
'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'forge'),
            'username'  => env('DB_USERNAME', 'forge'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

I'm not using forge - so, do I replace the "forge" with "local" as in the first line of my .env file ?

APP_ENV=local

or do I change the name of my .env file to local.env ??

Am I correct in believing that I can have multiple different environments, but how do I switch between them ?

Also I see on Matt Stauffers site, references to this:

$env = $app->detectEnvironment(function()
{
    return getenv('APP_ENV') ?: 'production';
});

Jeffrey nor the L5 docs do not talk about this - what do I do with this ??

Sorry if I'm being stupid here, but I can't see it written down anywhere.

Many Thanks !

stefanbauer's avatar

In L5 there is only one .env file. This should be not tracked in your git. There you can define all environment variables. If you use env('DB_HOSTNAME', 'Whatever') does just mean: Have a look in the .env file if there is DB_HOSTNAME defined. If yes, take that, otherwise fall back to the default (here: Whatever). So just use different .env files for your environments. If you don't define an environment in your .env file, it is automatically "production".

vincej's avatar

Many Thanks !

Ok, I remove "forge" and put in something else, like, "local" then local becomes the fall back.

in my one .env file I can have production, staging and local ? So, how do I switch between them ?

So, what do I do with this:

$env = $app->detectEnvironment(function()
{
    return getenv('APP_ENV') ?: 'production';
});

If I need it - where do I find it ?

Vielen Dank !

lihaibh's avatar

@mattstauffer the files history is not saved after git squash... https://laracasts.com/discuss/channels/requests/l5-upgrade-squashing-commits-to-preserve-file-history

You sure it worked for you? I also see in your project that some files lost their continuity for example the app.php configuration file. you can see here: https://github.com/mattstauffer/savemyproposals/commit/ee822774117d510a4b563434e7c05698ed787aaf you changed this file on 20 Dec 2014, yet if you look in the file history here: https://github.com/mattstauffer/savemyproposals/commits/master/config/app.php

You can see that the earlier commit associate with this file was on Jan 15, 2015 when you upgraded your project to L5. Am i missing something?

By the way there is another guide for upgrading to laravel 5, by organize your directory structure rather than remove and reinstall everything. U can check here: http://matthewhailwood.co.nz/upgrading-laravel-to-5-0/

jeitnier's avatar

The struggle I'm facing currently is how to explain to my non-technical client the benefits of upgrading to 5.x. It's a large production app and will no doubt take days to upgrade and fully test and money is a big impediment for him. As a developer, of course I understand the benefits and would gladly pull the trigger on an upgrade. But that isn't so easy for a client shelling out the money. Obviously using PHP 7 is out of the question at the moment, but what other things could I explain to justify my reasons?

ohffs's avatar

I think 4.2 will be EOL'd at some point soon unless they increase the usual 1yr support mark. I'd guess when 5.3 comes out maybe? From https://laravel.com/docs/5.1/releases#support-policy :

For general releases, bug fixes are provided for 6 months and security fixes are provided for 1 year.

And I think 5.0 came out around February last year. I imagine if there was something really gaping/critical they'd fix it - but other than that...

1 like
acasar's avatar

@jeitnier Well in my experience there is simply no way to explain it :) Only when it gets considerably more expensive to maintain the old code - then it's something clients can understand. Even security issues don't really matter to them.

Just recently I was able to upgrade a 10 year old PHP codebase (that required PHP 5.2 to run!) to a newer version. And the reason? Large new feature that would take 5 times longer to implement in the old code base. So in my experience, money is the only trigger for most of the clients :) Sad, but true.

But if you succeed with some other argument, please let me know how you did it :)

1 like
Previous

Please or to participate in this conversation.