Crud Ci 4

  1. Need to add migration for make CRUD
    • Migration step using CLI
      • Run command php spark make:migration
      • After that need to enter class name migration
      • Will generate file on app/database/migrations
      • Then run php spark migrate
  2. After migration proceed to generate controllers file
    • Controller step using CLI
      • Run command php spark make:controller
        • In CRUD scenario we can use –restful
      • After that need to enter class name controller
      • Then controllers file will be generated with function default Restful function
  3. Then generate model
    • Model step using CLI
      • Run command php spark make:model
      • After that need to enter class name model
      • Then model will be generated like this
      • Setup allowed fields
  4. Then we will start with listing using function index
    • add code for query data using model
    • add index.php in folder students
    • add code for view listing in index.php
    • then go to app/config/routes.php setup routes for listing
  5. Next we go to create
    • In function new load view for create
    • In view file add form code
    • Then add code at function create for insert data
    • Setup routes like this
  6. After create we continue with Update
    • Add code at function edit with view file

    • Then we add function update
    • Setup routes
  7. Lastly, we make function delete
    • Just add process for delete at function delete
    • Setup routes
  8. Settle !!!

Note: Goodluck on your CRUD using CI4

Setup Supervisor Worker

  1. Enabled service for supervisor
    • in my situation i enable supervisor services on runcloud
  2. Then Login in terminal server
  3. Go to supervisor.d
    cd /etc/supervisor.d
  4. Then vim a file name u want to add
    • in my situation i add ci-worker.conf
      /etc/supervisor.d $ vim ci-worker.conf
  5. Then add this code into your file
    [program:ci-worker]
    command=php /home/example/webapps/app-example/index.php worker process_example_queue
    autostart=true
    autorestart=true
    stderr_logfile=/var/log/ci-worker.err.log stdout_logfile=/var/log/ci-worker.out.log
    • for /home/example/webapps/app-example/index.php is your web application path
    • for worker is your controller name
    • for process_example_queue is your function in controller to be excute
    • stderr_logfile & stdout_logfile is generated log for monitoring. U can specify path for log file to be generated
  6. After finish add file for worker can run both script
    • sudo supervisorctl reread
    • sudo supervisorctl update
  7. Then u can run to restart worker process
    • sudo supervisorctl restart ci-worker

Notes

  1. For check all status for worker u can run
    • sudo supervisorctl status
  2. If u make changes in worker file changes not be effected immediately u need to restart your worker like step no 8.

Local changes overwrite merge

When get this error in Run Cloud at Git/Deployment Error
  • Step to resolve error
    • Discard changes affected in server
      • can check all changes using
        git status (in superuser do mode)
      • can discard all changes
        git checkout . (in superuser do mode)
      • for discard a changes file
        git restore <file> (in superuser do mode)
    • Change ownership for file
      • after discard changes ownership file will change to root
      • can change ownership fill to old owner
        chown <owner name>:<group name> <file name> (in superuser do mode)

How to login server without password

  1. On server side
    1. Add directory .ssh if dont have
    2. Add file authorized_keys in directory .ssh
    3. In file authorized_keys can put your ssh key
  2. On local side
    • Set ~/.ssh
      1. If dont have file config in .ssh can add file config
      2. If have can add code
        Host host-name //use for login
        Hostname 123.233.443.422 //server Ip address
          Preferredauthentications publickey
          User system-user //system user

        Note : please remove comment before paste code
      3. After that u can login server using ssh host-name

Change background in vsc

  1. Download extension background


  2. In vscode run Cmd/Ctrl + shift + p then choose open settings (JSON)
  3. Copy this code & paste into open settings (JSON)
{
    "background.enabled": true,
    "background.loop": false,
    "background.useDefault": false,
    "background.useFront": false,
    "background.style": {
        "content": "''",
        "pointer-events": "none",
        "position": "absolute",
        "z-index": "99999",
        "width": "100%",
        "height": "100%",
        "background-position": "center",
        "background-size": "contain",
        "background-repeat": "no-repeat",
        "opacity": 0.1
    },
    "background.customImages": [
        "https://img.indianautosblog.com/2018/10/20/honda-cbr250rr-tricolour-right-front-quarter-db72.jpg"
    ]
}