Wednesday, 28 February 2024

Ec-Cube tutorial

* Setup Ec-cube

- Install Ec-cube

- Using Symfony Profiler

* Feature Customization

- Validation by Using ValidatorInterface & Entities

- Directory/file structure

- Functions list

Customizing Controller

- Customizing Entities

- Customizing the repository

- Customizing Form Type

- Customizing the throttling function

- Customize the template

- Customize your purchase flow

- Customize order status

- Allow list control with Twig Sandbox 

- Customization using Symfony features

* Customize Principle

- Customize follow guide of Ec-cube
- If not support then customize directly to src/Eccube, because:
+ Change to one store to multi stores
+ Change purchase flow to many store
=> Have to customize src/Eccube if needed

* Design Customization

- Basics of design templates

- Use of blocks

- Using layouts

- Using .twig

- Image management

- Use of CSS

- Use Sass (scss)

- Change form layout

- Customize message

* Develop a plugin

- Installing plugins

- Develop a plugin

- Test a plugin 

* Advanced feature

- Using domPdf in Eccube with Svg, Font family 

- Sync & Queued Message Handling

* Security Guidelines

- About Coding

- About Deploying

 Thank you

Friday, 23 February 2024

Install Git

* Install Git

$ sudo apt install git-all

* Connect to github.com using ssh in linux

- generate ssh key

$ ssh-keygen -t ed25519 -C "your_email@example.com"

+ enter ssh file name: id_ed25519

+ enter password, re password

- Start the ssh-agent in the background

$ eval "$(ssh-agent -s)"

- add your SSH private key to the ssh-agent.

$ ssh-add ~/.ssh/id_ed25519

- add config file

$ sudo nano config

Host github.com
  IdentityFile ~/.ssh/
id_ed25519

- add key in id_ed25519.pub to ssh key in guthub

- check ssh success

$ ssh -T git@github.com

* >> some error can happen

Refference: 

> https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

Install Mysql

1. Install on Ubuntu

- update server

> sudo apt update
- install mysql server
> sudo apt install mysql-server
- adjust how your root MySQL user authenticates 
> sudo mysql
> mysql >> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
> mysql >> exit
> mysql -u root -p
> ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;
- run the security script with sudo:
> sudo mysql_secure_installation
+ option set password validation 
+ follow to create new password 
2. Creating a User and Granting Privileges 
- access mysql
> sudo mysql -u root -p 
- create user
> mysql >> CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password';
- create database
> mysql >> CREATE DATABASE test_database; 
mysql >> USE test_database;
- add user and grant privileges
> mysql >> CREATE USER ‘test_database_admin’@’localhost’ IDENTIFIED BY ‘test_password’; 
> mysql >> GRANT ALL PRIVILEGES ON test_database TO ‘test_database_admin’@’localhost’;
 

Thank you 

 

Thursday, 22 February 2024

Errors when ssh to github but don't has permission

1. not add config for authentication

~/.ssh/config

Host github.com
  IdentityFile ~/.ssh/ssh_github_vps

Host bitbucket.org
  IdentityFile ~/.ssh/ssh_bitbucket_vps

2. Wrong user authentiaction

- you access to user by user user_xxx

- you don't have permission to call git clone then you use sudo => you is root user

=> wrong user in config of ssh => error don't has permission

Fix:

- whoami => user_xxx

- groups => groups u in => user_xxx

sudo chow -R user_xxx:user_xxx www

(www is folder has source)

Thank you


Monday, 19 February 2024

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (in Mysql 5.6)

In Mysql 5.6, when you hit the limit. Set the following.
INNODB utf8 VARCHAR(255)
INNODB utf8mb4 VARCHAR(191)

Because: 767 bytes in MySQL version 5.6 (and prior versions), is the stated prefix limitation for InnoDB tables. It's 1,000 bytes long for MyISAM tables. This limit has been increased to 3072 bytes In MySQL version 5.7 (and upwards).

References:

- https://stackoverflow.com/questions/1814532/mysql-error-1071-specified-key-was-too-long-max-key-length-is-767-bytes

- https://viblo.asia/p/su-khac-nhau-giua-2-storage-engine-myisam-va-innodb-bJzKmgVPl9N

Thank you

Thursday, 1 February 2024

Fake data & Testing withLaravel Dusk other system

I. Fake Data with Laravel for other system

- Build laravel project

- Config to connect databases of other system, with files

.env, config/database.php

- Using models, factories, migrations, seeders, faker inlaravel to fake data 


II. Using Laravel Dusk to test for other system

1. Install Laravel Dusk

composer require laravel/dusk --dev

php artisan dusk:install


More detail: https://laravel.com/docs/10.x/dusk 

2. Generating & Run Tests

Generating Test

php artisan dusk:make LoginTest


Example: test login success

<?php


namespace Tests\Browser\External;


use App\Models\User;

use Laravel\Dusk\Browser;

use Tests\DuskTestCase;


class ExternalTest extends DuskTestCase

{

    public function test_login_successful(): void

    {

        $this->browse(function (Browser $browser) {

            $browser->visit('http://demo.test/login')

                    ->type('email', 'admin@example.com')

                    ->type('password', 'password')

                    ->click('#login-button')

                    ->assertSee('Login successful');

        });

    }

}



Example: test create object error with error message

<?php


namespace Tests\Browser\External;


use App\Models\User;


use Laravel\Dusk\Browser;

use Tests\DuskTestCase;


class External2Test extends DuskTestCase

{


    public function test_page_create_post_then_return_error_mgs(): void

    {

        $this->browse(function (Browser $browser) {

            $browser->visit('http://demo.test/admin/post/create')

            ->type('title', ‘post’')

            ->type('keyword', 'demo ')

            ->type('content', 'Your text goes here')
            ->attach('input[name="image"]', __DIR__.'/files/your-file.jpg')  

            ->click('#bt-submit-form-post')

            ->pause(1000)

            ->assertSee('Trường tiêu đề bài viết phải lớn hơn 5 ký tự.');

        });

    }

}



Run Tests

php artisan dusk


3. Methods supoort when test with laravel dusk

* Support interact with browser
- InteractsWithAuthentication: loginAs, logout, currentUserInfo, assertAuthenticated...
- InteractsWithCookies: cookie, plainCookie, addCookie, deleteCookie…
- InteractsWithElements: elements, clickLink, type, typeSlowly, append, clear, select, radio, check, uncheck, attach, press, pressAndWaitFor, drag, acceptDialog, typeInDialog, dismissDialog...
- InteractsWithJavascript: script
- InteractsWithKeyboard: withKeyboard,parseKeys
- InteractsWithMouse: moveMouse, mouseover, click, clickAtXPath, clickAndHold, doubleClick, rightClick…
- WaitsForElements: whenAvailable, waitFor, waitUntilMissing, waitUntilMissingText, waitForText, waitForTextIn, waitForLink, waitForInput, waitForRoute, waitUntilEnabled, waitForDialog, waitForReload, waitForEvent….
* Support assert results
- MakesAssertions: assertTitle, assertHasCookie, assertSee, assertDontSee, assertSeeIn, assertSourceHas… (too many)
- MakesUrlAssertions: assertUrlIs, assertHostIs, assertPortIs, assertPathIs, assertPathIsNot, assertRouteIs
Thank you

References: https://laravel.com/docs/10.x/dusk

Publish npm package

  Để publish   pav-kit  lên NPM, bạn hãy làm theo các bước dưới đây. Tôi đã tạo thêm file  index.js  để đảm bảo gói tin hợp lệ. Bước 1: Tạo ...