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

rfm's avatar
Level 2

Problem creating Laravel project, Laravel installed on WAMPserver

I followed the procedure shown in this video by Dani Krossing titled: 2 | How to Easily Install Laravel | Laravel for Complete Beginners | Laravel Tutorial. https://www.youtube.com/watch?v=iBaM5LYgyPk

Everything went well until 23:30 where my database only has the "migrations" and "users" tables. I am using WAMPserver, have been for a few years now, where he has "DASHBOARD" I have "laravel" and where he has "firstwebsite" I have "prj01". I'm using PHP 8.3.6, and MySQL 8.3.0 and Apache 2.4.59. I created the local host "prj01" pointing to the "laravel/prj01/public" folder and when I click on it I get the following error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'prj01.sessions' doesn't exist (Connection: mysql, SQL: select * from `sessions` where `id` = ...omitted... limit 1)

The "sessions" table was not created nor all the other tables shown at 23:30. I've deleted everything and redid all a few times, same results every time. Why are all the other tables not being created. It obviously has access to the "prj01" table because it creates the "migrations" and "users" tables.

0 likes
42 replies
jlrdw's avatar

In development just change session to file. (used to be the default).

rfm's avatar
Level 2

@jlrdw Thanks you for your reply, however, I'm new to Laraval, I don't know what you mean by "In development". Will this fix the problem so that all new projects I create as shown at 20:30 of his video this problem will not occur? Note: This system will not allow me to post links my first day here, otherwise I would have given the link to his video.

jlrdw's avatar

@rfm development is programming the app, testing, etc. Production is when it's on a live server on the web.

I suggext Mysql and either Apache or Nginx for development.

But as @puklipo said, I suggest taking the free php course first if new to all of this.

rfm's avatar
Level 2

@jlrdw Hmmm, it appears that at best you skimmed my first post without picking up important details such as "I'm using PHP 8.3.6, and MySQL 8.3.0 and Apache 2.4.59" and "have been for a few years now" except of course that the versions were earlier versions. "In development" does not tell me where to "change session to file." As I said "I'm new to Laraval", just heard a lot of good things about it so thought I'd give it a try. As far as Laravel is concerned, it does not know whether it is XAMP or WAMP. The command executed in the "laravel" directory: "laravel new prj01" obviously executed its code via PHP 8.3.6 and in the "prj01" database it created two tables "migrations" and "users", and it created the "prj01" directory in the "laravel" directory and filled that directory with all the things it is supposed to according to the aforementioned video (still won't let me post a link to the video) as seen at time index: 25:09. The problem I encountered has nothing to do with my PHP programming skills, I've been programming in PHP for several years. So, again, why did "laravel" (the PHP code developed by the Laravel team) not create all the other tables in the "prj01" database as seen in said video at time index 23:30? It only created the two tables "migrations" and "users". When I click to load the (laravel/prj01/index.php) into the browser I get the aforementioned error that it cannot find the "sessions" table. Why was it and several other tables not created when it created the "migrations" and "users" tables? I should not have to debug Laravel's PHP code? The only material difference between the system being used in the video and mine is that my version of Laravel may be newer. My PHP version and MySQL versions are newer. However, not that much newer. And as I said before: "I followed the procedure shown on this video by Dani Krossing titled: 2 | How to Easily Install Laravel | Laravel for Complete Beginners | Laravel Tutorial. Everything went well until 23:30" I really hope you don't simply skim this post and make more erroneous assumptions and therefore erroneous assertions/comments/suggestions.

jlrdw's avatar

@rfm no I read about the wamp server, I was refering to using Mysql instead of sqlite or using apache or nginx instead of php artisan serve as @puklipo mentioned.

It's good to have a stack like you will use in production.

rfm's avatar
Level 2

@jlrdw Let's see:

  1. My first post I state: "I'm using PHP 8.3.6, and MySQL 8.3.0 and Apache 2.4.59."
  2. One of your replies to said post: "I suggext Mysql and either Apache or Nginx for development."

I told you I'm using MySQL and you then suggest that I use MySQL. I told you I'm using Apache and you then suggest that I use Apache.

  1. You say: "But as @puklipo said, I suggest taking the free php course first if new to all of this."

"@puklipo" never suggested such, however "@Tray2" gave me a link to such a course, which I'm half way through.

puklipo's avatar

Don't use weird videos made by beginners as a reference.

This video is completely different from how advanced users use Laravel. https://www.youtube.com/watch?v=iBaM5LYgyPk

  1. If you are using Windows, first install WSL. Throw away XAMPP etc.
  2. Install PHP and composer on Ubuntu in WSL.
  3. Install laravel/installer.
  4. Create a Laravel project.

The default server as of Laravel 11 is php artisan serve and the database is SQLite.

If you can't understand this explanation, you need to learn the basics of PC and PHP before Laravel. Laravel is not for beginners. Don't jump straight into Laravel.

rfm's avatar
Level 2

@shaungbhone I have a few projects in WAMPserver and have no problems with it. I'm used to it and I prefer not to have yet another development system. Not all my projects will be laravel, will "Herd" only allow laravel projects? Have you used WAMP or XAMP and if so, what are the benefits of "Herd" over "WAMP"?

rfm's avatar
Level 2

@shaungbhone Sorry, I never trust anyone that says "trust me", especially when they cannot tell me why, such as "what are the benefits of 'Herd' over 'WAMP'?", which probably means you never used WAMP, at least sufficiently enough, and therefore don't know why you believe "Herd" is better than "WAMP". This makes you appear as a promoter of a product you may financially benefit from.

Tray2's avatar

This is the best place to start with Laravel

https://laracasts.com/series/30-days-to-learn-laravel-11

You should use Herd for your local development, it's by far the easiest, it gives you everything you need as long as you use SQlite database, and as a beginner who is learning it's good enough. Herd is a first party application from Larvel and Beyond Code.

https://herd.laravel.com/

If you feel that you need another database, I suggest getting dbnging, it makes it super easy to spin up different versions of the database.

https://dbngin.com/

rfm's avatar
Level 2

@Tray2 Thank you for your reply. I'm now half way through "30-days-to-learn-laravel-11". Laravel seems to be as good as I've heard and read about. The only thing I'm learning is Laravel. My first paid for software engineering job was in 1976 when I developed an accounting package (GL, AR, AP, PR, INV) in machine code, 0s and 1s for an accountant who used it for a few years until he hired me to find him a multi-user computer system and program an accounting package to run on it, which I did. I have programmed in over 30 programming languages, packages such as Accounting for accountants/CPAs/bookkeepers, Electric billing for electricity providers, Gas flow analysis natural gas supply companies, Timber management for timber companies, Retaining walls for retaining wall engineers, Costume jewelry POS and INV management for costume jewelry stores, Websites using PHP HTML CSS JS etc., and numerous others. I've always been one to not use platforms because I prefer to know exactly what is going on everywhere. Laravel interested me, so thought I'd look into it. I've never had such difficulty getting something up and running as Laravel. I have yet to see why "Herd" is better than "WAMP". As far as "DBngin" goes, with "WAMP" I can easily switch and use different databases and versions of said database as well as different versions of PHP. I haven't seen any reason to switch from "WAMP" as of yet, I may come across one in the future, who knows.

Tray2's avatar

@rfm Wamp works perfectly fine, but with Herd you get a an easy way to use multiple versions of php, and node on a per project bases, and with zero configuration you get custom domains for each of your projects, simply just create an new project folder in you Herd directory, and you have that directory name dot test available.

  1. laravel new blog / composer create-project laravel/laravel blog
  2. visit blog.test

The reason I suggested using dbngin is that you can easily spin up a new database server within seconds. You need a Redis server version 3, or perhaps 4, 5, 6, or 7, or maybe you need a MySQL 5.7, or a more recent version 8 for a project, or another client might want Postgreesql, well you just spin up an instance of of that. You can basically have as many servers running as you need.

rfm's avatar
Level 2

@Tray2 I have installed DBngin to see what it does. It seems to be a great solution. Would be nice if it would run with WAMPserver, can't find anything on the internet addressing that possibility.

So, when using Herd, the (name of the project).test in the browser address bar will load the initial page "(name of the project).public.index.php"? Does Herd change the "C:\Windows\System32\drivers\etc\hosts" file to accomplish that?

I know what the "laravel new blog" does, but I do not know what you mean by "composer create-project laravel/laravel blog", is this creating a project "laravel blog" in the "laravel" directory? Or perhaps creating a "blog" project in a created directory "laravel" within a directory "laravel"?

Last week I finished the "30-days-to-learn-laravel-11" course, when time allows I'll do it again but this time I'll follow along by doing it in my project as well since I am now able to create new projects without errors.

Tray2's avatar

@rfm Herd + DBNgin is what you should use together, if you use wamp, then you already have everything installed. It works but it's no where near as good as Herd + DBNgin.

acuarelasoft's avatar

there are 2 options, first option: in the .env file change session driver from database to file like this: SESSION_DRIVER=file

second option: if you want to use session driver database you should create the migration and run it with this artisan commands:

php artisan make:session-table php artisan migrate

rfm's avatar
Level 2

@acuarelasoft Thank you for your reply. Finally one that doesn't make assumptions. When I run: "laravel --version" it replies with "Laravel Installer 5.8.3", which should be the most recent one as of a few days ago.

  1. What driver does this version recommend: database or file?
  2. What is the benefit of "file" over "database"?
  3. For all the other tables that were not created in the "prj01" database, will I have to "php artisan make:(table name)-table php artisan migrate"?

I'd still like to know why it worked on his system on the video and not mine, any idea?

Snapey's avatar

@rfm instead run php artisan -v if you want to know what version you are on

run php artisan db:show to see what database Laravel thinks it is working with.

rfm's avatar
Level 2

@Snapey Hello:

php artisan -v returns among other things: Laravel Framework 11.22.0

php artisan db:show returns among other things: MySQL ... 8.3.0

Snapey's avatar

@rfm you dont have to pay per line of text posted here. I was hoping to see your database name and table names

rfm's avatar
Level 2

@Snapey I did give the information you requested. Following is lots of details:

========================================

C:\wamp64\www\laravel>dir
 Volume in drive C is Acer
 Volume Serial Number is 9CE7-F03B

 Directory of C:\wamp64\www\laravel

09/11/2024  10:25 AM    <DIR>          .
09/12/2024  03:00 PM    <DIR>          ..
09/11/2024  10:26 AM    <DIR>          prj01
               0 File(s)              0 bytes
               3 Dir(s)  223,875,321,856 bytes free

========================================

C:\wamp64\www\laravel\prj01>php artisan -v
Laravel Framework 11.22.0

Removed the rest since it is simply instructions.

========================================

C:\wamp64\www\laravel\prj01>php artisan db:show
  MySQL ........................................................................................................ 8.3.0
  Connection ................................................................................................... mysql
  Database ..................................................................................................... prj01
  Host ..................................................................................................... 127.0.0.1
  Port .......................................................................................................... 3306
  Username ...................................................................................................... root
  URL ................................................................................................................
  Open Connections ................................................................................................. 1
  Tables ........................................................................................................... 2
  Total Size ................................................................................................. 2.00 KB
  Table ......................................................................................................... Size
  migrations ................................................................................................. 1.00 KB
  users ...................................................................................................... 1.00 KB

========================================

I have deleted the "prj01" directory:

C:\wamp64\www\laravel>dir
 Volume in drive C is Acer
 Volume Serial Number is 9CE7-F03B

 Directory of C:\wamp64\www\laravel

09/15/2024  07:16 AM    <DIR>          .
09/12/2024  03:00 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  223,979,335,680 bytes free

========================================

I DROPped the "prj01" database

MySQL:3306/ http://localhost/phpmyadmin/index.php?route=/server/sql Your SQL query has been executed successfully.

show databases;

information_schema	
mysql	
performance_schema	
sys	

========================================

I will now create a new project and capture the command output:

========================================

C:\wamp64\www\laravel>dir
 Volume in drive C is Acer
 Volume Serial Number is 9CE7-F03B

 Directory of C:\wamp64\www\laravel
09/15/2024  07:35 AM    <DIR>          .
09/12/2024  03:00 PM    <DIR>          ..
09/15/2024  07:36 AM    <DIR>          prj01
               0 File(s)              0 bytes
               3 Dir(s)  223,904,419,840 bytes free

========================================

========================================

MySQL:3306/ http://localhost/phpmyadmin/index.php?route=/server/sql Your SQL query has been executed successfully.

show databases;

information_schema	
mysql	
performance_schema	
prj01	
sys	
prj01
    migrations
    users

========================================

The "laravel new prj01" command created the prj01 directory and put all the directories and files into it indicated above in the command output section. It also created the "prj01" database and the two tables indicated above.

I noticed the following error in the command output section above:

 SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (Connection: mysql, SQL: alter table `users` add unique `users_email_unique`(`email`))

  at vendor\laravel\framework\src\Illuminate\Database\Connection.php:825
*    821▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
*    822▕                 );
*    823▕             }
*    824▕
*   ➜ 825▕             throw new QueryException(
*    826▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
*    827▕             );
*    828▕         }
*    829▕     }

  1   vendor\laravel\framework\src\Illuminate\Database\Connection.php:571
      PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes")

  2   vendor\laravel\framework\src\Illuminate\Database\Connection.php:571
      PDOStatement::execute()

========================================

I've searched for the solution of that error. Some of the solutions simply say to update to newer version of MySQL, I aleady am using a version newer than the version they say to upgrade to, so that is not the answer. I'll look into other supposed solutions.

========================================

What I've learned with the https://laracasts.com/series/30-days-to-learn-laravel-11 course, which I'm now at day 21 (of course I couldn't practice because I can't get a working Laravel project going), I would like to use Laravel, but I need it to install correctly for each project I will be working on, which there are currently three new projects, one will use "MariaDB" and two will use "PostgreSQL" for the databases will be huge. I do not want to have to manually correct things every time I start a new project.

It is unacceptable that I would have to correct errors every time I create a new project.

rfm's avatar
rfm
OP
Best Answer
Level 2

@acuarelasoft I did some research and what you suggest is one of the answers I've often found.

In the "your_project\app\Providers\AppServiceProvider.php" you add the following:

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

Some say that doing the above places a limit on the number of columns.

Some say that in "your_project/config/database.php" change:

"'engine' => 'null'," to "'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',"

However, doing any of the above means for every project I create I will need to make those changes and migrate again. To me, this is not a good solution, in fact it is an unacceptable solution.

I did what others suggested and it worked. This is what I did:

Now I can created projects without having to edit things within the project or migrate again after the edits. This is the best solution I have found and suggest that Laravel puts this solution in place of having to edit any project files.

Snapey's avatar

take a moment to stop and understand the contents of the .env file. This contains default. settings for your app.

These defaukts have changed in the latest release with sqlite being used as the defaukt database driver.

Also, if you want to use mysql for database and for the sessions driver then you will need to edit your .env file to tell the framework, and run an artisan command to create the sessions table in the database. This guys video is probably out of date so you may get some discrepancies.

You can see all the artisan commands by running just php artisan

rfm's avatar
Level 2

@Snapey I totally understand the .env file and nothing there solves the problem.

My reply to @acuarelasoft states what I did to solve the problem and I do not have to edit any project file. Link to my reply: https://laracasts.com/discuss/channels/laravel/problem-creating-laravel-project-laravel-installed-on-wampserver?reply=948161

Is there a way to put a clickable link in a post such as this so that clicking it brings you to the post the link is to?

Snapey's avatar

why do you think you are running both mariadb and mysql? If you are, you will only be connecting to the one bound to port 3306

rfm's avatar
Level 2

@Snapey So, the gist of what you are saying is that even though the time I chose "MariaDB" which runs on port 3307, it still ran the server on port 3306 which is "MySQL", that's why the project database and tables were created in "MySQL" instead of "MariaDB". The project installation procedure should not only ask for what database server to use, it should ask what port to run on and create/modify the ".env" file accordingly. Better yet, there should be a port lookup file where the project installation procedure can look up the appropriate port to use for a given database server.

rfm's avatar
Level 2

@Snapey You say "Why should the vast majority have to answer questions because a tiny minority have a non-standard setup?" I didn't know it was mandatory for the "vast majority" to answer. And if the "20 people have replied" is the "vast majority" there must not be very many people using Laravel.

There are a great number of people using WAMPserver, I've been using it for years, written lots PHP and JS code for the projects I set up under WAMPserver. I don't consider that a minority.

Even if I set up the project with Herd or any other set up way the "vast majority" uses, I would have encountered the same error, and many others have, see "Stack Overflow" on the matter. And most of those are using, as you say, the "vast majority" setup.

jlrdw's avatar

@rfm remember the install has changed, it used to default to mysql and file session. It's just a simple (a few seconds) matter to change an install to the way you choose.

I prefer composer and not the laravel installer.

rfm's avatar
Level 2

@jlrdw As I stated in my first post, I'm new to Laravel, so I've seen no change, therefore, to me your statement "remember the install has changed" means nothing to me for I have nothing to compare it to.

jlrdw's avatar

@rfm You have the prior documentation to compare with once it was mentioned.

rfm's avatar
Level 2

@jlrdw I prefer to move forward rather than learning how things were to compare that to how things are now.

jlrdw's avatar

@rfm

I prefer to move forward rather than learning how things were to compare that to how things are now.

Using mysql is not moving backwards or using file for session is not moving backwards.

Laravel 11 just changed the default install for the "development" setup.

rfm's avatar
Level 2

@jlrdw I never said "Using mysql" or "using file for session" is moving backwards. Having to read "prior documentation" is moving backwards. I'm not interested in what "prior documentation" (which I do not have) says, I'm only interested in what the current documentation says. It is rather sad that I have to explain such to you.

Snapey's avatar

@rfm just FYI, documentation for all versions is via the dropdown top right of the docs. You should know about this because sometimes answers here and on google generally might link to the specific version of the docs and you might need to change from 8 to 11 for instance to know if the approach is still relevant.

Please or to participate in this conversation.