Laravel – No supported encrypter found. The cipher or key length are invalid.

A user was trying to install Laravel under WAMP and got the following error:

RuntimeException in compiled.php line 6904: No supported encrypter found. The cipher and / or key length are invalid.

Looking at the Laravel installation instructions, the only WampDeveloper specific change that would need to be done is to load the PHP sockets extension:

1. Open file C:\WampDeveloper\Config\Php\php.ini (via Notepad)

2. Find this line and uncomment it (remove front “;”) –


3. Save file. Restart Apache.

All the other Laravel required PHP extensions and Apache modules under WampDeveloper are loaded and enabled by default.

The above error seems to be Laravel-specific (rather than having something to do with WAMP) and here is how to fix it…

1. Make sure that in Laravel’s config\app.php file, the 'cipher' is defined as so:

'cipher' => 'AES-256-CBC',

2. Make sure Laravel’s “.env” file exists. If this file does not exist, open the command-line (run cmd.exe), change the command-line’s “working directory” to Lavavel’s installed-to path, and create this file from the provided example template file:

cd \path\to\laravel\folder
cp .env.example .env

The first line (“C:”) changes to drive “C”, the second line changes to the path (on C)… substitute-in for your Laravel installed location. The third line makes a properly-named copy of the base example file. Because this file starts with a period, it’s much simpler to make a copy using the command-line (otherwise you’ll run into issues).

3. The cause of the issue is – the above cipher “AES-256-CBC” needs a 32 character key, but the default random key is only 16 characters long.

Generate a new 32 character string for the key by running (from cmd.exe):

php artisan key:generate

The command should automatically update the app.php file (and also the .env file) with a new proper-size key, and output something similar to this afterwards:

Application key [g8MOZ9dYU4ap5F12m95PIPAA5AJG3Sh6] set successfully.

4. Verify that the above key is now in Laravel's .env file:


If it's not, manually add it in as shown above (substitute in your key, and without the brackets).

* On another unrelated but similar cause, if this is happening sometime after a successful installation - after your app is fully installed and running - then it is possible that the APP_KEY was changed and now the encrypted data cannot be decrypted. In this case, unless you can revert to the previous key, you'll have to either delete the encrypted data or start over.

MySQL ERROR 1045 (28000): Access denied for user ‘db_user_name’@’localhost’

I have software that requires direct access to the MySQL database. If I run it on the same computer as WAMP it works, but if I access the database with this software from another computer, it then reports error:

MySQL ERROR 1045 (28000): Access denied for user 'db_user_name'@'localhost' (using password: YES)

Create the same database user (i.e., with the same name + password as the existing user) in MySQL (via \phpmyadmin), except set the “Host:” field to either the connecting remote IP address, or to “%” (which means any IP can connect).

This way you’ll be able to use this user to access the database from (Host:, and also from an outside system (Host:%).

Also make sure that you have already:

  • Re-bound MySQL from IP to
  • Opened incoming port 3306 requests in Windows Firewall (and removed any existing blocking MySQL rules).
  • Port-forwarded port 3306 in the Router from WAN:3306 to LAN-IP:3306 (if accessing from outside the LAN).

And that this database user has all permissions granted on the specific database(s), and the outside application is using the proper: IP, database name, user name, user password – to establish the connection.

If you have the mysql client on the remote system, you can also manually test this from the command-line via:

mysql -u db_user_name -p -h -P 3306

Accessing MySQL or phpMyAdmin From Outside

Running .NET 3.5 App on .NET 4.5 of Windows 8 and Server 2012

There is a very easy way to run .NET 3.5 applications under .NET 4.5 (and 4.0), without having .NET 3.5 installed…

Edit the application’s app.exe.config file:


And within the “<configuration>” section, add in the support for runtime v4:

  <supportedRuntime version="v2.0.50727"/>
  <supportedRuntime version="v4.0"/>

The above configuration will have the system use .NET 3.5 if it finds it [.NET v3.5 uses runtime “v2.0″], otherwise it will use .NET 4.0 or 4.5 (which use runtime “v4.0″).

And if your application is having issues (e.g., nothing shows on-screen except the application border with a background color inside) on a Windows 7 + (or Server 2008 +) system with .NET v4, that also has .NET 3.5 enabled, try placing the <suppportedRuntime version="v4.0"/> line above the 2.0 line – so it tries to use .NET v4 first… As some systems with both .NET v4 and v3.5 have the later in a corrupted state.

Whether this works depends on whether the code used in the application is compatible with the changes that were made in the newer releases of .NET version and runtime. Most applications will be 100% compatible with the higher version.

Related Information

1. Graph of the default .NET version that shipped with the Windows OS version:
Windows .NET Versions

2. Microsoft documentation on the above configuration changes: How to Configure an App to Support .NET Framework 4 or 4.5

3. Microsoft documentation on which versions of .NET that can be installed per Windows OS version: .NET Framework Versions and Dependencies

MySQL Error “Incorrect integer value ” for column ‘name’ at row 1″

If a PHP script tries to set a string value, such as an empty string, into a MySQL integer data type or column, you will likely see this error message:

Incorrect integer value ” for column ‘name’ at row 1

In this situation, what is happening is that the script is attempting to insert or update a row with the integer entry taking on either the default value (e.g., of 0 or NULL) or the next AUTO_INCREMENT value.

But MySQL is not interpreting this action as valid due to its SQL_MODE being in STRICT mode.

In this case, to not treat this action as an error, edit my.ini and comment out (#) this line:


Save my.ini, restart MySQL.

Afterwards, the value of '' (empty string) will just default to whatever:

A. Is specified as the default value of the column (set when the table was created).

B. Is the underlining designated default value for the integer data type.

If this does not help, then the script needs to be searched (in your editor of choice) for the column name, and the PHP code or the SQL statements on the found lines edited to set either a proper value, or the column name removed from those statements.

Auto Correct Broken and Mis-Encoded Links to Your Site

Some percentage of the posted links on the internet to your site will contain commonly made typing mistakes that result in the visitor ending up on a 404 / “Not Found” page.

By using Apache’s mod_rewrite and the RewriteRule directive, you can easily auto-correct the majority of the badly-formed incoming links, by reforming the broken links and then redirecting to the correct URL.

A normal link to your website on another website looks like this:

<p>Some text with a <a href="">link anchor text here</a>.</p>

There are several ways this link can be malformed.

Incorrect HTML character encoding/escaping:;&gt;...

Two links combined:

Dots, commas, quotes, parentheses, angle quotes at end:,"'<>

White-spaces at end: <-- a space here

Link, line break, paragraph, list tags at end:</a><br></p></li>

Variations of above:<a><a/><a</br><br /><p><p/><li>

Fix Broken Incoming Links

To automatically correct the above common link mishaps, place the following code into either the website’s VirtualHost or .htaccess file.

# match on some common link mishaps: link">... escaped as link&quot;&gt;abcdefg
RewriteRule ^(.*)\s*(&quot;)+(&gt;)* $1 [R=permanent,L]

# match on some common link mishaps: two links merged
RewriteRule ^(.*)\s*https?:// $1 [R=permanent,L]

# match on some common link mishaps: ending tags and variations such as <br> <br/> <br /> </br> ... <a <a> <a > </a </a> ...
RewriteRule (.*)\s*</?a\ ?/?>?$ $1 [R=permanent,L]
RewriteRule (.*)\s*</?br\ ?/?>?$ $1 [R=permanent,L]
RewriteRule (.*)\s*</?li\ ?/?>?$ $1 [R=permanent,L]
RewriteRule (.*)\s*</?p\ ?/?>?$ $1 [R=permanent,L]

# match on some common link mishaps: links ending with . , " ' ) ( > < or any whitespace character (on specific single match, with it being one or more times)
RewriteRule (.*)[\.,"'\)\(><\s]+$ $1 [R=permanent,L]

# match on some common link mishaps: multiple ending / (more than 1 ending forward slash)
RewriteRule (.*)//+$ $1/ [R=permanent,L]

Automatically Recover From MySQL Crashes and Table Errors

Repair Existing Crashed Databases and Tables

From the command line, run a general check and repair of all MyISAM and InnoDB tables:

mysqlcheck -u root -p --auto-repair --check --optimize --all-databases

The MySQL Services has to be running for “mysqlcheck” to work.

If MySQL will not start (and only in this case), run myisamchk with the path to MySQL’s data directory:

myisamchk --recover C:/WampDeveloper/Database/mysql-data-56/*/*.MYI

Auto Repair Future Crashed Databases and Tables

Edit MySQL’s my.ini file and tell MySQL to auto recover MyISAM tables as they are opened:

# For MySQL 5.1
# For MySQL 5.5.3+

Remove the myisam-recover option “BACKUP” if this is happening often, as the backup files will accumulate and grow in number (and the overall size becomes a problem).

InnoDB tables automatically recover after every crash, and no additional configuration is needed… Unless the InnoDB data is so corrupt that MySQL will not start.

Trace Crashes to Specific Query

If you log all the queries made, the last one before the crash will likely be the one that is causing crashes and corruption. And from it, you can trace the issue back to its origin…

general_log = 1
general_log_file = "C:/mysql-query.log.txt"

How to Redirect “/” Root URL to Another Sub-Directory or URL

A typical redirect is usually done from either:

  1. The entire website to another website:
    Redirect /
  2. Or from one specific path of a website to another location:
    Redirect /path

The limitation of Apache’s Redirect directive is that you cannot redirect just the root URL “/”, and nothing after it, to another path or location. As Redirect matches everything after the given path, whatever follows it, and a redirect from “/” is a redirect of all the website’s URLs.

Use RedirectMatch to redirect the root URL “/” to another sub-directory or URL…

RedirectMatch ^/$

Since RedirectMatch uses a regex, it can be specific with the “/” path without matching anything more.