The time of year I hate the most, because I absolutely don’t like aging.
But we can’t change the fact, I turned 29.
We went for a weekend to the ardennes. Where I tested our new Drone, the DJI Mavic 2 Pro.
301 Redirects are permanent redirections, so it redirects a certain URL to another one.
301 redirects are added to the .htaccess file on an Apache server.
Redirect 301 [old page url] [new page url]
Redirect 301 /oldpage.html https://www.url.tld/newpage.html Redirect 301 /oldpage2.html https://www.url.tld/newpage2.html Redirect 301 /oldpage3.html https://www.url.tld/newpage3.html
For an entire website:
Redirect 301 / https://www.newurl.tld
Here’s an overview of what you could use while developing a project with Laravel.
In order to create controllers, models, migrations, … we can use artisan.
php artisan make:controller MyController
When we want artisan to provide a controller with the “resource functions” (index, create, store, show, edit, update, destroy) predefined for us, we can simply add “–resource” to our command to provide these functions out of the box.
php artisan make:controller MyController --resource
php artisan make:model
If you want artisan to provide a migration file related to our newly created model, you can just add “-m” to the command. Which gives us something like this:
php artisan make:model -m
We’re also able to create our own migration file, for example is we want to add field to an existing table or create a pivot table, or …
php artisan make:migration the_name_of_your_migration
Just like the migration file that artisan provided for us when we used -m on the creation of a model, the migration file will be added to the /database/migrations folder.
In order to get our migration file(s) migrated into the database, we need to tell artisan to migrate them. Like so:
php artisan migrate
Be aware that once a migration file has been migrated to the database, all changes to the file afterwards will be discarded. We’ll need to create a new migration file in order to add additional changes / migrations. In the database you can see the hierarchy of the migrations in the table “migrations”.
Installing Laravel and getting your project going is quite easy, if you know how to do it. So here we go!
First of all you’ll need a local server.
You’ll be needing at least PHP version 7.1.3. and I’m currently working on PHP 7.2.
I prefer to install Laravel globally. Use the following command on your terminal.
composer global require "laravel/installer"
After Laravel is installed you can run the simple command.
laravel new myFirstProject
And it will create a new folder for you with the name myFirstProject with a fresh installation of Laravel in it.
The next step is to set up your vhost to your folder. (don’t forget to link it to the public folder)
Once this is done, you’ll be able to browse to your newly created project using the browser of your choosing.
Installing Laravel using these steps will automatically result in a secure installation, meaning that there will be a Application Key generated for you.
Setting up a database for your project will be quite easy because we will be using the power of artisan to build our project.
The only thing you need to do manually is creating an empty database. Afterwards you’ll need to put in the credentials into the .env file, right over here:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret
When this is done we can start using the database.
From this point forward you can start developing your project!