https://askubuntu.com/questions/68175/how-to-create-script-with-auto-complete
This is good but sometimes I had to hit tab twice to see commands.
Thursday, 5 March 2020
Lumen tutorial 2 - Lumen + AWS
Tutorial:
https://medium.com/@igliop/https-medium-com-igliop-running-a-serveless-lumen-rest-api-on-aws-lambda-804089b0852c
I was following above site, but had error while using below. Localhost was working but not live url in aws.
$ sam package — template-file template.yaml — output-template-file serverless-output.yaml — s3-bucket yourbucketname
https://medium.com/@igliop/https-medium-com-igliop-running-a-serveless-lumen-rest-api-on-aws-lambda-804089b0852c
I was following above site, but had error while using below. Localhost was working but not live url in aws.
$ sam package — template-file template.yaml — output-template-file serverless-output.yaml — s3-bucket yourbucketname
Sunday, 1 March 2020
Lumen tutorial
Tutorial
https://auth0.com/blog/developing-restful-apis-with-lumen/
This link looks easy and thorough as well.
https://medium.com/@Dotunj/building-a-rest-api-with-lumen-403b67fec4d6
Following above url, I had below error.

Running tutorial on AWS Ubuntu live server
I also had below error.
Run below site with sudo.
https://auth0.com/blog/developing-restful-apis-with-lumen/
This link looks easy and thorough as well.
https://medium.com/@Dotunj/building-a-rest-api-with-lumen-403b67fec4d6
Following above url, I had below error.
Ins-MacBook-Pro:authors inheeoh$ php artisan make:migration create_authors_table
Created Migration: 2020_03_01_103525_create_authors_table
Ins-MacBook-Pro:authors inheeoh$ php artisan migrate
In Connection.php line 669:
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.t
ables where table_schema = matthew_schema and table_name = migrations and table_type = 'BASE TABLE')
In Connector.php line 70:
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
In Connector.php line 70:
PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]
I found the error reason is from my MySQL version 8.0
mysql> CREATE USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
Query OK, 0 rows affected (0.04 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
And changed .env file to use:
DB_DATABASE=matthew_schema
DB_USERNAME=user
DB_PASSWORD=yourpassword
mysql> select host, user from mysql.user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
| localhost | user |
+-----------+------------------+
5 rows in set (0.00 sec)
Finally success!
Ins-MacBook-Pro:authors inheeoh$ php artisan migrate
Migration table created successfully.
Migrating: 2020_03_01_103525_create_authors_table
Migrated: 2020_03_01_103525_create_authors_table (0.01 seconds)
Ins-MacBook-Pro:authors inheeoh$

Running tutorial on AWS Ubuntu live server
While creating 'authors' project, I had below error.
phpunit/phpunit 8.5.x-dev requires ext-dom * -> the requested PHP extension dom is missing from your system.
Found solution
You have to install php-xml
I also had below error.
The following exception is caused by a lack of memory or swap, or not having swap configured
Run below site with sudo.
https://stackoverflow.com/questions/38828224/composer-update-the-following-exception-is-caused-by-a-lack-of-memory-and-not-h
ubuntu@ip-172-31-16-44:~$ sudo /sbin/mkswap /var/swap.1
mkswap: /var/swap.1: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=ac8bde7a-0271-4a81-913d-66c3e5117556
ubuntu@ip-172-31-16-44:~$ sudo /sbin/swapon /var/swap.1
swapon: /var/swap.1: insecure permissions 0644, 0600 suggested.
Then I could install lumen >> authors project successfully !
Visual Code
Cmd-Shift-x: extensions search/install
Cmd-Shift-p: preview >> json prettify, live server etc
(or F1)
Cmd-Shift-p: preview >> json prettify, live server etc
(or F1)
scp
Copy file of AWS -> to my machine
Copy local files -> to AWS
Ins-MacBook-Pro:keypair inheeoh$ scp -i matt_singapore_ec2_keypair.pem ubuntu@13.251.213.109:~/bin/go* ~/aws/XAMPP/
gobin 100% 21 0.2KB/s 00:00
gohome 100% 18 0.2KB/s 00:00
gohtml 100% 34 0.3KB/s 00:00
goscript 100% 21 0.2KB/s 00:00
gowww 100% 34 0.3KB/s 00:00
Ins-MacBook-Pro:keypair inheeoh$ scp -i matt_singapore_ec2_keypair.pem ubuntu@13.251.213.109:/opt/lampp/htdocs/index* ~/aws/XAMPP/
index.html 100% 206 1.9KB/s 00:00
index.php 100% 261 2.4KB/s 00:00
Ins-MacBook-Pro:keypair inheeoh$
Copy local files -> to AWS
$ scp file1 file2 user@host:/path/to/directory # copying multiple files using scp command
$ scp -r /path/to/directory user@host:/path/to/directory # Copying an entire directory with scp command
https://devhints.io/scp
Ins-MacBook-Pro:keypair inheeoh$ pwd
/Users/inheeoh/Dropbox/TechDoc/AWS Documentation/keypair
Ins-MacBook-Pro:keypair inheeoh$ scp -i matt_singapore_ec2_keypair.pem ~/aws/XAMPP/*.html ubuntu@13.251.213.109:/opt/lampp/htdocs
index.html 100% 2692 23.2KB/s 00:00
index2.html 100% 206 1.6KB/s 00:00
Ins-MacBook-Pro:keypair inheeoh$
Saturday, 29 February 2020
Install MySQL on my mac
Download and install
https://dev.mysql.com/downloads/file/?id=492745
MySQL strong password
root
Kxx
Install MySQL workbench as well.
You can create a new schema (eg, matthew_schema) in MySQL workbench. It will show as below.
Some helpful, but too long video:
https://www.youtube.com/watch?v=UcpHkYfWarM
> mysql -u root -p
xxx
Start/Stop MySQL Server
https://osxdaily.com/2014/11/26/start-stop-mysql-commands-mac-os-x/
or
System preference >> MySQL
Samples
https://dev.mysql.com/downloads/file/?id=492745
MySQL strong password
root
Kxx
Install MySQL workbench as well.
You can create a new schema (eg, matthew_schema) in MySQL workbench. It will show as below.
Some helpful, but too long video:
https://www.youtube.com/watch?v=UcpHkYfWarM
> mysql -u root -p
xxx
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| matthew_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> use matthew_schema;
https://osxdaily.com/2014/11/26/start-stop-mysql-commands-mac-os-x/
or
System preference >> MySQL
Samples
mysql> select table_schema,table_name,table_type from information_schema.tables where table_schema = 'matthew_schema'
-> ;
+----------------+------------+------------+
| TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE |
+----------------+------------+------------+
| matthew_schema | t_test | BASE TABLE |
+----------------+------------+------------+
1 row in set (0.00 sec)
mysql> select table_schema,table_name,table_type from information_schema.tables where table_schema = 'matthew_schema' and table_name ='migrations' and table_type = 'BASE TABLE';
Friday, 28 February 2020
Install Lumen on your MacOS
https://medium.com/@igliop/https-medium-com-igliop-running-a-serveless-lumen-rest-api-on-aws-lambda-804089b0852c
29/2/20 The above link does not work for me. I had the below error while sam packaging.
Ins-MacBook-Pro:lambda-lumen-test inheeoh$ sam package --template-file template.yaml --output-template-file serverless-output.yaml --s3-bucket lumen-serverless-lambda
Traceback (most recent call last):
File "/usr/local/Cellar/aws-sam-cli/0.43.0/libexec/lib/python3.7/site-packages/samcli/yamlhelper.py", line 90, in yaml_parse
return json.loads(yamlstr, object_pairs_hook=OrderedDict)
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 361, in loads
return cls(**kw).decode(s)
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
To test Lumen on my mac, I had to install Composer first.
https://medium.com/@igliop/https-medium-com-igliop-running-a-serveless-lumen-rest-api-on-aws-lambda-804089b0852c
After doing trials for a while, I found that 'apt' is not command for mac, and you have to use 'homebrew'.
Ins-MacBook-Pro:~ inheeoh$ touch .bash_profile
Ins-MacBook-Pro:~ inheeoh$ vim .bash_profile
Ins-MacBook-Pro:~ inheeoh$ echo $JAVA_HOME
Ins-MacBook-Pro:~ inheeoh$ . .bash_profile
Ins-MacBook-Pro:~ inheeoh$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home
Ins-MacBook-Pro:~ inheeoh$
Ins-MacBook-Pro:~ inheeoh$
Ins-MacBook-Pro:~ inheeoh$
Ins-MacBook-Pro:~ inheeoh$ sudo apt update
Password:
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/bin/apt" (-1)
Install Composer with brew
https://gist.github.com/tomysmile/3b37ab4a1ddd604093fe724d0a882166
This takes a while, 10min?
Downloaded Command Line Tools for Xcode
Installing Command Line Tools for Xcode
Done with Command Line Tools for Xcode
...
Ins-MacBook-Pro:bin inheeoh$ composer -V
Composer version 1.9.3 2020-02-04 12:58:49
Ins-MacBook-Pro:bin inheeoh$
Ins-MacBook-Pro:bin inheeoh$ . goaws
Ins-MacBook-Pro:aws inheeoh$ pwd
/Users/inheeoh/aws
Ins-MacBook-Pro:aws inheeoh$ ls
Ins-MacBook-Pro:aws inheeoh$ cd lambda-lumen-test/
Ins-MacBook-Pro:lambda-lumen-test inheeoh$ ls
LICENSE README.md src template.yaml
Ins-MacBook-Pro:lambda-lumen-test inheeoh$ vim template.yaml
Ins-MacBook-Pro:lambda-lumen-test inheeoh$ pwd
/Users/inheeoh/aws/lambda-lumen-test
Ins-MacBook-Pro:lambda-lumen-test inheeoh$ cd src/php/lumen/
Ins-MacBook-Pro:lumen inheeoh$ composer update
Ins-MacBook-Pro:lumen inheeoh$ php -S localhost:8000 -t public
PHP 7.3.11 Development Server started at Sat Feb 29 14:15:52 2020
Listening on http://localhost:8000
Document root is /Users/inheeoh/aws/lambda-lumen-test/src/php/lumen/public
Press Ctrl-C to quit.
[Sat Feb 29 14:16:07 2020] [::1]:55050 [404]: /
[Sat Feb 29 14:16:07 2020] [::1]:55051 [404]: /favicon.ico - No such file or directory
[Sat Feb 29 14:16:13 2020] [::1]:55054 [200]: /hello
Subscribe to:
Posts (Atom)

