Email:   Password:
Blog :: Technical Learning by Thomas Riemer
RSS 2.0   RSS 1.0   Atom
laravel   (PDF)
Posted March 22nd, 2024

Laraval is a popular framework for php
1a. laravel required sqlite.
    > dnf install sqlite-devel
1b. To create a laravel project
    > composer create-project laravel/laravel:^11.0 project-name

2. So laravel when developing is generally done by running a local
   web server, which listens on port 8000.  From your project directory
   >  php artisan serve
   Now point your browser at http://localhost:8000

3. in the app:
   config directory - has configuration files.
       (app.php is main one)



4. So I chose to use postgres to use as a database.

A. create user and database
   > sudo -u postgres psql
   > create user foo password 'bar';
   > create database fubardb owner foo;

configure postgresql in .env in top level of project

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=fubardb
DB_USERNAME=foo
DB_PASSWORD=bar

configure /var/lib/pgsql/data/pg_hba.conf
change the line for for ipv4 to:
(ident needs to change to trust)
host    all             all             127.0.0.1/32            trust

5. So this doesn't work...
   need to compile pgsql, and/or mysql
   So php needs to be compiled with flags
   ./configure --with-pdo-mysql=mysqlnd \
       --with-pdo-pgsql=mysqlnd \
       --with-pgsql \
       --with-mysqli

   // Laravel uses the PDO objects in its database access.

6. run php artisan migrate:fresh
   this generates the user account handling stuff for laravel
   

7. Routes are in the routes subdiretory
   routes/web.php

   To add an api
   php artisan install:api
   This generates routes/api.php
   
8. Creating a table in Laravel - Migration
   > php artisan make:migration migration_name

   This creates a php object datestamped, with the migration name in
   database/migrations

   The object has an up and down function.
   So to create the table update the up function.
   
   
public function up(): void
    {
        Schema::create('cave', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->text("description");
            $table->string("city");
            $table->string('county');
            $table->string('state');
            $table->text("directions");
            $table->datetime("created");
            $table->string("source");
            $table->string("gps");
            $table->string("altitude");
            $table->string("depth");
            $table->string("length");
            $table->string("managedby");
            $table->string("area");
            $table->string("landowner");
            $table->timestamps();
        });
        
    }
    

   



Copyright © 2024 Mind Contract, Inc.   All Rights Reserved
For more information call thomasriemer49@gmail.com or email 720-883-1866
Powered By: Build a Member