Enable Putenv () in PHP

Hello,
why you have disabled putenv, it is the most required function for an laravel application.
please consider enabling it. i am student and want it to be enabled for my ongoing projects. please enable putenv, it could be great for other users also. Hoping a positive response from your side.
Infinityfree is a great service, thank you for the great work

I just did a quick check and I can’t find any code in Laravel or it’s required dependencies which requires putenv to be available. There are some exceptions with tests and console commands, but neither of those things should/can be run on a live website anyways.

Also, please keep in mind that even if the function was required and is enabled, Laravel was definitely not designed with shared hosting in mind. Laravel’s heavy reliance on custom server configurations and console commands means it runs far better on an application hosting service like Heroku.

yes, i know laravel is not designed for shared hosting, but my project is a simple light weight laravel project which works fine on shared hosting itself.
i cannot afford heroku, since i am a student. please enable putenv() on your server. it could be useful to other loyal users of infinityfree host. please consider enabling it. Hoping a positive response from your side.
Infinityfree is a great service, thank you for the great hosting service for free

@Stranger said:
yes, i know laravel is not designed for shared hosting, but my project is a simple light weight laravel project which works fine on shared hosting itself.

No, it doesn’t. Laravel requires you to change the document root of your website, which is not possible on free hosting.

@Stranger said:
i cannot afford heroku, since i am a student.

Heroku has a free tier. It’s small, but you can host a Laravel site on it (I do so as well).

Also, since you’re a student, you can get the GitHub Student Developer Pack: https://education.github.com/pack This pack contains plenty of freebies, like free DigitalOcean and Amazon Web Services credit, which are both more suitable hosting for applications than a website hosting account. Amazon has Beanstalk, which is a bit like Heroku. Or you could use a tool like Dokku, which is a nice and simple self hosted Heroku alternative.

@Stranger said:
please enable putenv() on your server. it could be useful to other loyal users of infinityfree host. please consider enabling it.

Again, Laravel doesn’t require putenv() as far as I can tell. What tells you that it is?

heroku, digitalocean, amazon asks for credit card, which i dont have. just enable putenv on your servers. i am not asking you for anything. it will help me for my project. please understand. tell me openly that you can enable it for me or not.

thank you

@Stranger said:
heroku, digitalocean, amazon asks for credit card, which i dont have. just enable putenv on your servers. i am not asking you for anything. it will help me for my project. please understand. tell me openly that you can enable it for me or not.

thank you

Again, Laravel doesn’t require putenv() as far as I can tell. What tells you that putenv is required?

laravel has .env file. All environment variables of my project are stored in env file. this is the basic structure for an laravel framework. so to write and read that file putenv and getenv is used.

so please enable that putenv() on your hosting with kind hearted. please …

laravel has .env file. All environment variables of my project are stored in env file. this is the basic structure for an laravel framework. so to write and read that file putenv and getenv is used.

so please enable that putenv() on your hosting with kind hearted. please …

@Stranger said:
laravel has .env file. All environment variables of my project are stored in env file. this is the basic structure for an laravel framework. so to write and read that file putenv and getenv is used.

so please enable that putenv() on your hosting with kind hearted. please …

Again, Laravel doesn’t need putenv(). You don’t need that function to use Laravel. I know, I have hosted Laravel on free hosting before with the function disabled.

Yes, Laravel is configured through environment variables. And Laravel also checks .env files. getenv() is used to read the environment settings. But at no point does Laravel need to write to the environment. Writing the configuration is something you do manually, or through whatever method your hosting platform offers you (which we don’t because, again, we provide website hosting, not application hosting).

I have combed through the code used to parse the .env file and I found that putenv was used in there like this:

        if (function_exists('putenv')) {
            putenv("$name=$value");
        }

As you can see, this code will work fine without the putenv function. It will just skip the step if the putenv function is not available.

So once more, putenv() is not required for Laravel. Flattery won’t make me push for a change which affects millions of websites.

my project is configured to write the environment values to env file through putenv
i cannot skip that, because my project will automatically change the values in env through putenv. My project is designed like that. Without putenv my project will not work. so please help me with your kind heart. please enable that function for me.

just changing the value in php.ini to enable putenv does not affect any of your users website. Infact your Millions of user will be happy and thankful to you including me, if you enable putenv…

please enable it. hoping for an positive response from your side

@Stranger said:
my project is configured to write the environment values to env file through putenv

So the issue is that your project requires a function which is not supported. This is not an issue with Laravel support. That’s an important distinction to make.

Also, the .env file is just a file. You can change it with any file changing function (fopen, file_put_contents, etc.). putenv changes environment variables. You don’t need to change environment variables to change a file which is used to configure environment variables.

i cannot skip that, because my project will automatically change the values in env through putenv. My project is designed like that. Without putenv my project will not work. so please help me with your kind heart. please enable that function for me.

I’m sorry, but in case it wasn’t clear yet: I cannot make this change for you.

The PHP settings are controlled centrally. There is no way to set specific PHP settings for specific accounts. So changing any PHP settings would change them for all websites, and we cannot change settings which affects millions of websites just because one person asks for it.

More fine grained control of PHP settings, as well as generally having more access to PHP functions, is restricted to premium hosting only. So you may need to upgrade your account to use this function.

@Stranger said:
just changing the value in php.ini to enable putenv does not affect any of your users website.

That’s because you can’t access the php.ini files. You can create a php.ini file anywhere, but the server won’t read it.

@Stranger said:
Infact your Millions of user will be happy and thankful to you including me, if you enable putenv…

I really doubt your reasoning here that millions of users will be thankful for this change. Did you notice all the people in this topic saying “yes! please! we need this!”? No? Me neither. Because very few people ask for this feature.

I must admit, you’re not the first person asking for this feature. But every time someone asked for putenv before, they needed it for the BeMusic script. BeMusic is a music uploading/sharing script, which is not allowed on our hosting to begin with. I’m not sure what kind of software you’re trying to host, but I’m not particularly looking forward to changing a setting which most users will use to violate our terms and abuse server resources.

1 Like