Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By laravista

Thread: Laravel 11 on Altervista 🎅 (still works!)

  1. #1
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    53

    Default Laravel 11 on Altervista 🎅 (still works!)

    Hi all,

    I am working to migrate all my LaraVista projects on Laravel 11

    alemoppo likes this.

  2. #2
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    53

    Default

    1) Pre-requisites


  3. #3
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    53

    Default

    2) Install Laravel 11

    • Execute the Docker commands to build, run and exec
    • Check PHP and Composer versions inside Docker (after exec command) with:
      Code:
      root@7dcdc16d865d:/var/www/html# php -v
      PHP 8.2.6 (cli) (built: May 23 2023 09:42:25) (NTS)
      
      root@7dcdc16d865d:/var/www/html# composer -v
         ______
        / ____/___  ____ ___  ____  ____  ________  _____
       / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
      / /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
      \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                          /_/
      Composer version 2.5.7 2023-05-24 15:00:39
    • Create the new application L11x
      Code:
      root@7dcdc16d865d:/var/www/html# /root/.composer/vendor/bin/laravel new L11x

  4. #4
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    53

    Default

    3) Laravel project setting (interactive mode)

    • Choose No starter kit and PHPUnit
      Code:
      root@7dcdc16d865d:/var/www/html# /root/.composer/vendor/bin/laravel new L11x
      
         _                               _
        | |                             | |
        | |     __ _ _ __ __ ___   _____| |
        | |    / _` | '__/ _` \ \ / / _ \ |
        | |___| (_| | | | (_| |\ V /  __/ |
        |______\__,_|_|  \__,_| \_/ \___|_|
      
      
       ┌ Would you like to install a starter kit? ────────────────────┐
       │ No starter kit                                               │
       └──────────────────────────────────────────────────────────────┘
      
       ┌ Which testing framework do you prefer? ──────────────────────┐
       │ PHPUnit                                                      │
       └──────────────────────────────────────────────────────────────┘
      
      Creating a "laravel/laravel" project at "./L11x"
      Installing laravel/laravel (v11.5.0)
        - Installing laravel/laravel (v11.5.0): Extracting archive
      Created project in /var/www/html/L11x
      Loading composer repositories with package information
      Updating dependencies
      Lock file operations: 110 installs, 0 updates, 0 removals
        - Locking brick/math (0.12.1)
        - Locking carbonphp/carbon-doctrine-types (3.2.0)
      
      [... MORE]
      
        - Installing phpunit/phpunit (11.5.2): Extracting archive
      65 package suggestions were added by new dependencies, use `composer suggest` to see details.
      Generating optimized autoload files
      81 packages you are using are looking for funding.
      Use the `composer fund` command to find out more!
      No security vulnerability advisories found
      > @php -r "file_exists('.env') || copy('.env.example', '.env');"
      
         INFO  Application key set successfully.
    • Choose MySQL database and No migrations
      Code:
       ┌ Which database will your application use? ───────────────────┐
       │ MySQL                                                        │
       └──────────────────────────────────────────────────────────────┘
      
       ┌ Default database updated. Would you like to run the default database migrations? ┐
       │ No                                                                               │
       └──────────────────────────────────────────────────────────────────────────────────┘
      
         INFO  Application ready in [L11x]. You can start your local development using:
      
      ➜ cd L11x
      ➜ npm install && npm run build
      ➜ composer run dev
      
        New to Laravel? Check out our bootcamp and documentation. Build something amazing!

  5. #5
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    53

    Default

    4) .htaccess (local develpment)

    • Add this .htaccess file into src/L11x folder:
      Code:
      <IfModule mod_rewrite.c>
          RewriteEngine On
          RewriteBase /L11x
          RewriteRule ^(.*)$ public/$1 [L]
      </IfModule>
    • Update src/L11x/.env with your local database:
      Code:
      DB_CONNECTION=mysql
      DB_HOST=host.docker.internal
      DB_PORT=3306
      DB_DATABASE=laravel
      DB_USERNAME=root
      DB_PASSWORD=pass

  6. #6
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    53

    Default

    5) MySQL tables "prefix"

    • To avoid problem with the new database schema and the old projects we have to use the 'prefix' => 'l11x_'
      Code:
              'mysql' => [
                  'driver' => 'mysql',
                  'url' => env('DB_URL'),
                  'host' => env('DB_HOST', '127.0.0.1'),
                  'port' => env('DB_PORT', '3306'),
                  'database' => env('DB_DATABASE', 'laravel'),
                  'username' => env('DB_USERNAME', 'root'),
                  'password' => env('DB_PASSWORD', ''),
                  'unix_socket' => env('DB_SOCKET', ''),
                  'charset' => env('DB_CHARSET', 'utf8mb4'),
                  'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
                  'prefix' => 'l11x_',
                  'prefix_indexes' => true,
                  'strict' => true,
                  'engine' => null,
                  'options' => extension_loaded('pdo_mysql') ? array_filter([
                      PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
                  ]) : [],
              ],
    • Execute the migration command:
      Code:
      root@7dcdc16d865d:/var/www/html/L11x# php artisan migrate
      
         INFO  Preparing database.  
      
        Creating migration table ...................................................................................... 83.71ms DONE
      
         INFO  Running migrations.  
      
        0001_01_01_000000_create_users_table ......................................................................... 120.54ms DONE
        0001_01_01_000001_create_cache_table .......................................................................... 33.61ms DONE
        0001_01_01_000002_create_jobs_table ........................................................................... 79.59ms DONE
    • and check the result on your database:
      Code:
      SHOW TABLES
      
      l11x_cache
      l11x_cache_locks
      l11x_failed_jobs
      l11x_job_batches
      l11x_jobs
      l11x_migrations
      l11x_password_reset_tokens
      l11x_sessions
      l11x_users

  7. #7
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    53

    Default

    6) .htaccess (Production)

    • Copy .htaccess.prod to .htaccess
    • Copy .env.prod to .env with your AlterVista database configuration, for example:
      Code:
      DB_CONNECTION=mysql
      DB_HOST=localhost
      DB_PORT=3306
      DB_DATABASE=my_laravista
      DB_USERNAME=laravista
      DB_PASSWORD=
    • The best way to deploy is uploading the src/L11x folder with zip -r L11x.zip L11x
    • After you can check your website https://laravista.altervista.org/L11x/

  8. #8
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    53

    Default

    7) Create "l11x_sessions" table

    • You can not execute the migrate command on AlterVista because you need a terminal (for example SSH)
    • so you have to export the database schema, for example with MySQL Workbench (Data Export)
    • and execute the create script on AlterVista PhpMyAdmin
      Code:
      CREATE TABLE `l11x_sessions` (
        `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
        `user_id` bigint(20) unsigned DEFAULT NULL,
        `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        `user_agent` text COLLATE utf8mb4_unicode_ci,
        `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
        `last_activity` int(11) NOT NULL,
        PRIMARY KEY (`id`),
        KEY `l11x_sessions_user_id_index` (`user_id`),
        KEY `l11x_sessions_last_activity_index` (`last_activity`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    • now you can check again your website https://laravista.altervista.org/L11x/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO