feat: Laravel 12 quickstart with tests#7028
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
rfay
left a comment
There was a problem hiding this comment.
Looks to me like it's just what we need! Thanks!
| DDEV defaults to using a MariaDB database to better represent a production environment. | ||
|
|
||
| To select the [Laravel 11 defaults](https://laravel.com/docs/11.x/releases#application-defaults) for SQLite, use this command for `ddev config`: | ||
| To select the [Laravel defaults](https://laravel.com/docs/11.x/releases#application-defaults) for SQLite, use this command for `ddev config`: |
There was a problem hiding this comment.
| To select the [Laravel defaults](https://laravel.com/docs/11.x/releases#application-defaults) for SQLite, use this command for `ddev config`: | |
| To use a SQLite database when creating a new project, replace the `ddev config` command with the following instead: |
This removes the link, which is a moving target.
| !!!tip "Want to use a SQLite database for Laravel?" | ||
| DDEV defaults to using a MariaDB database to better represent a production environment. | ||
|
|
||
| To select the [Laravel 11 defaults](https://laravel.com/docs/11.x/releases#application-defaults) for SQLite, use this command for `ddev config`: | ||
| To select the [Laravel defaults](https://laravel.com/docs/11.x/releases#application-defaults) for SQLite, use this command for `ddev config`: | ||
| ```bash | ||
| ddev config --project-type=laravel --docroot=public --omit-containers=db --disable-settings-management=true | ||
| ``` | ||
|
|
There was a problem hiding this comment.
A problem with this section is that only applies when starting a new project.
For existing projects you need to:
- update
.envtoDB_CONNECTION="sqlite"
ddev config --project-type=laravel --docroot=public --omit-containers=db --disable-settings-management=true
ddev restart
ddev artisan migrate:freshIf you don't update the .env you will get the following error (included for searchability):
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for db failed: Name or service not known (Connection: mariadb, SQL: select * from `sessions` where `id` = jvwGaqOpdMyrsUZa412ljRqpuaNOIqPSw2NJE2XN limit 1)
There was a problem hiding this comment.
Nice catch!
I think we should put the SQLite config on a separate tab, where we mention how to migrate from one to the other.
If we add everything on one tab, it will complicate things for newcomers.
rpkoller
left a comment
There was a problem hiding this comment.
looks good (tested the composer and laravel isntaller steps), i left one comment on the tests and two observations about applying the laravel installer quickstart:
-
i am not sure if i have tested the laravel installer before, but somehow i only copy and pasted the echo line
echo 'ARG COMPOSER_HOME=/usr/local/composerthen thought i'Ve missed the single quote, after another try it dawned to me that it is a single command. for readability the current version is definitely better but it could be misleading like in my case. therefore i wonder if putting it in a single line would be the more clear choice? -
for
ddev exec laravel new temp --database=sqlitewould it make sense to add to the comment before the commant, that the the user should follow the defaults none and for picking no starterkit to install and yes for running the npm build?
|
|
||
| run curl -sf https://${PROJNAME}.ddev.site | ||
| assert_success | ||
| assert_output --partial "Laravel" |
There was a problem hiding this comment.
I wonder if it would make sense to slightly extend the assertion and use <title>Laravel</title>instead? would be still prone to potential updates but still more specific than just Laravel? (if so it would have to be applied to line 127 as well)
There was a problem hiding this comment.
I wonder if it would make sense to slightly extend the assertion and use <title>Laravel</title>instead?
If the database setting are incorrectly set by DDEV, the resulting error page contains the word "Laravel" and the header "<title>Laravel</title>".
If I recall, there were some shenanigans with collation settings and Laravel 11. Would the tests have caught that issue?
There was a problem hiding this comment.
i just manually tested and changed the DB_HOST from db to dbs in the .env file. after that curl -sf https://lari.ddev.site returns nothing so i suppose the assertion would fail in that case
There was a problem hiding this comment.
curl -sf https://lari.ddev.site returns nothing while curl -sfI https://lari.ddev.sitereturns:
HTTP/2 500
cache-control: no-cache, private
content-type: text/html; charset=UTF-8
date: Fri, 28 Feb 2025 04:20:43 GMT
server: nginx
There was a problem hiding this comment.
Ah, so it would be caught by assert_output --partial "HTTP/2 200" then.
Thank you for checking.
There was a problem hiding this comment.
yep, even both assertions would fail. neither the 200 nor the Laravel one would pass.
@rpkoller, I think it was the syntax highlighting that confused you. I'll replace it with
If people use Laravel Installer, it usually means that they want to use StarterKit. I will make the comment clearer about the choice, thank you! |
5198bd3 to
31ab5c9
Compare
|
I updated Laravel Quickstart with Composer (SQLite) and made some small changes to Laravel Installer. |
0c8835a to
98b4be5
Compare
| ddev composer run-script post-root-package-install | ||
| ddev dotenv set .env --db-connection=sqlite | ||
| ddev composer run-script post-create-project-cmd |
There was a problem hiding this comment.
post-root-package-install copies .env.example to .env if it doesn't exist, then we set the sqlite connection in .env, and finally run migrations in post-create-project-cmd.
tyler36
left a comment
There was a problem hiding this comment.
Looks good.
I was able to create a project with the "default" mariadb database, then convert to Sqlite database.
Thank you!
There was a problem hiding this comment.
thanks for the changes. the syntax highlighting makes it way clearer now and the comment i've raised looks good now as well. and i've ran through the two tests another time and all worked well. added only one more comment about one small stumbling block i havent noticed in the previous review.
| @@ -507,28 +533,37 @@ The Laravel project type can be used for [StarterKits](https://laravel.com/docs/ | |||
| mkdir my-laravel-site && cd my-laravel-site | |||
| ddev config --project-type=laravel --docroot=public | |||
There was a problem hiding this comment.
there is only one minor nitpick about a detail i've just noticed. line 536 refers to line 534 stating that it is using mariadb, while line 538 uses sqlite instead. the detail i dont understand, with the active default you set the project up for mariadb but in line 553 sqlite is used anyway? that is not entirely clear to me why you use mariadb and sqlite alongside?
and in general the comment in 536 is hard to comprehend cuz it requires that you jump in-between lines referring to the lines before and after the comment. Plus if the quickstart states "This config uses.." strictly speaking me as the recipient would expect that line 538 would set up mariadb. how about something like the following instead?
# To use MariaDB apply the following command
ddev config --project-type=laravel --docroot=public
# To use SQLite, uncomment and use the following command instead
#ddev config --omit-containers=db --disable-settings-management=true
There was a problem hiding this comment.
but in line 553 sqlite is used anyway?
It's because if you specify a different database (other than SQLite) at this point, the database migrations will fail, which would cause more confusion. You can try it with:
ddev exec laravel new temp
ddev exec laravel new temp --database=mariadb
I don’t have access to alter the .env content when running laravel new.
I tried to make the comment for ddev exec laravel new temp --database=sqlite a bit clearer.
how about something like the following instead?
# To use SQLite, uncomment and use the following command instead
Good idea! I think it's better to add --project-type=laravel --docroot=public in this case when we say "instead".
There was a problem hiding this comment.
ah thanks for the explanation. i like the improvements you made to the comment! and yep i also agree adding --project-type=laravel --docroot=public. looks good, thank you!

The Issue
Laravel 12 was released https://laravel.com/docs/12.x/releases
How This PR Solves The Issue
Manual Testing Instructions
https://ddev--7028.org.readthedocs.build/en/7028/users/quickstart/#laravel
Automated Testing Overview
Release/Deployment Notes