# PHP Configuration Setup Guide

This guide explains how to enable the necessary PHP settings for the YouTube MP3 Downloader on different hosting types.

## Required PHP Settings

The application requires:
- ✅ `allow_url_fopen = On` (REQUIRED - allows file_get_contents() to open URLs)
- ✅ `max_execution_time = 300` (recommended for large downloads)
- ✅ `memory_limit = 256M` (recommended for large files)

## Setup Methods by Hosting Type

### Method 1: .htaccess (Apache/Shared Hosting)

**Most common method for shared hosting**

1. Upload the `.htaccess` file to your website root directory
2. The settings will apply automatically if your host supports it
3. If it doesn't work, your host may have disabled `.htaccess` overrides

### Method 2: .user.ini (cPanel/Some Shared Hosting)

**Works on cPanel and some other control panels**

1. Upload the `.user.ini` file to your website root directory
2. Wait a few minutes for changes to take effect (cPanel caches PHP settings)
3. You may need to restart PHP or wait up to 5 minutes

### Method 3: php.ini (VPS/Dedicated Server)

**For VPS or dedicated servers where you have full control**

1. Edit your main `php.ini` file (location varies by system)
2. Or create a local `php.ini` in your website directory
3. Restart your web server (Apache/Nginx)

### Method 4: cPanel MultiPHP INI Editor

**If you have cPanel access**

1. Log into cPanel
2. Go to "MultiPHP INI Editor" or "Select PHP Version" → "Options"
3. Enable `allow_url_fopen`
4. Set `max_execution_time` to 300
5. Set `memory_limit` to 256M
6. Click "Save"

### Method 5: Contact Your Hosting Provider

**If none of the above work**

Contact your hosting provider and ask them to:
- Enable `allow_url_fopen` for your account
- Increase `max_execution_time` to 300 seconds
- Increase `memory_limit` to 256M

## Verifying Settings

Create a test file `test_php_settings.php`:

```php
<?php
echo "allow_url_fopen: " . (ini_get('allow_url_fopen') ? 'Enabled ✓' : 'Disabled ✗') . "<br>";
echo "max_execution_time: " . ini_get('max_execution_time') . " seconds<br>";
echo "memory_limit: " . ini_get('memory_limit') . "<br>";
echo "upload_max_filesize: " . ini_get('upload_max_filesize') . "<br>";
echo "post_max_size: " . ini_get('post_max_size') . "<br>";
?>
```

Upload it and visit it in your browser to check if settings are applied.

## Troubleshooting

### "allow_url_fopen is disabled" error

**Solution:** Your hosting provider has disabled this setting. You need to:
1. Try using `.htaccess` or `.user.ini` (see methods above)
2. Contact your hosting provider to enable it
3. Consider switching to a hosting provider that allows it

### Settings not taking effect

1. **Wait a few minutes** - Some hosts cache PHP settings
2. **Clear any caching** - Clear browser cache and any server-side cache
3. **Check file location** - Make sure `.htaccess` or `.user.ini` is in the root directory
4. **Check file permissions** - Files should be readable (644 permissions)
5. **Check error logs** - Look for PHP errors in your hosting control panel

### Still having issues?

If your hosting provider doesn't allow `allow_url_fopen`, you have these options:
1. Switch to a hosting provider that allows it (most shared hosting does)
2. Use a VPS where you have full control
3. Contact your hosting provider - many will enable it upon request

## Security Note

The application is designed to work without dangerous functions like `shell_exec`, `exec`, or `proc_open` for security. It only requires `allow_url_fopen`, which is a standard and safe setting that most hosting providers allow.
