IMG-LOGO

Tutorial

IMG
CodeIgniter 4 : Running Your App
20 Sep-2021

A CodeIgniter 4 app can be run in a number of different ways: hosted on a web server, using virtualization, or using CodeIgniter’s command line tool for testing. This section addresses how to use each technique, and explains some of the pros and cons of them.

Initial Configuration & Set Up

  1. Open the app/Config/App.php file with a text editor and set your base URL. If you need more flexibility, the baseURL may be set within the .env file as app.baseURL=”http://example.com/”. (Always use a trailing slash on your base URL!)
  2. If you intend to use a database, open the app/Config/Database.php file with a text editor and set your database settings. Alternately, these could be set in your .env file.

One additional measure to take in production environments is to disable PHP error reporting and any other development-only functionality. In CodeIgniter, this can be done by setting the ENVIRONMENT constant, which is more fully described on the environments page. By default, the application will run using the “production” environment. To take advantage of the debugging tools provided, you should set the environment to “development”.

Local Development Server

CodeIgniter 4 comes with a local development server, leveraging PHP’s built-in web server with CodeIgniter routing. You can use the serve script to launch it, with the following command line in the main directory:

php spark serve

This will launch the server and you can now view your application in your browser at http://localhost:8080.

Note

The built-in development server should only be used on local development machines. It should NEVER be used on a production server.

If you need to run the site on a host other than simply localhost, you’ll first need to add the host to your hosts file. The exact location of the file varies in each of the main operating systems, though all unix-type systems (include OS X) will typically keep the file at /etc/hosts.

The local development server can be customized with three command line options:

  • You can use the --host CLI option to specify a different host to run the application at:

    php spark serve --host example.dev
    
  • By default, the server runs on port 8080 but you might have more than one site running, or already have another application using that port. You can use the --port CLI option to specify a different one:

    php spark serve --port 8081
    
  • You can also specify a specific version of PHP to use, with the --php CLI option, with its value set to the path of the PHP executable you want to use:

    php spark serve --php /usr/bin/php7.6.5.4
    

Hosting with Apache

A CodeIgniter4 webapp is normally hosted on a web server. Apache’s httpd is the “standard” platform, and assumed in much of our documentation.

Apache is bundled with many platforms, but can also be downloaded in a bundle with a database engine and PHP from Bitnami.

.htaccess

The “mod_rewrite” module enables URLs without “index.php” in them, and is assumed in our user guide.

Make sure that the rewrite module is enabled (uncommented) in the main configuration file, e.g., apache2/conf/httpd.conf:

LoadModule rewrite_module modules/mod_rewrite.so

Also make sure that the default document root’s <Directory> element enables this too, in the “AllowOverride” setting:

<Directory "/opt/lamp/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Virtual Hosting

We recommend using “virtual hosting” to run your apps. You can set up different aliases for each of the apps you work on,

Make sure that the virtual hosting module is enabled (uncommented) in the main configuration file, e.g., apache2/conf/httpd.conf:

LoadModule vhost_alias_module modules/mod_vhost_alias.so

Add a host alias in your “hosts” file, typically /etc/hosts on unix-type platforms, or c:/Windows/System32/drivers/etc/hosts on Windows. Add a line to the file. This could be “myproject.local” or “myproject.test”, for instance:

127.0.0.1 myproject.local

Add a <VirtualHost> element for your webapp inside the virtual hosting configuration, e.g., apache2/conf/extra/httpd-vhost.conf:

<VirtualHost *:80>
    DocumentRoot "/opt/lamp/apache2/htdocs/myproject/public"
    ServerName myproject.local
    ErrorLog "logs/myproject-error_log"
    CustomLog "logs/myproject-access_log" common
</VirtualHost>

If your project folder is not a subfolder of the Apache document root, then your <VirtualHost> element may need a nested <Directory> element to grant the web server access to the files.

Testing

With the above configuration, your webapp would be accessed with the URL http://myproject.local in your browser.

Apache needs to be restarted whenever you change its configuration.

Hosting with Nginx

Nginx is the second most widely used HTTP server for web hosting. Here you can find an example configuration using PHP 7.3 FPM (unix sockets) under Ubuntu Server.

This configuration enables URLs without “index.php” in them and using CodeIgniter’s “404 - File Not Found” for URLs ending with “.php”.

server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    root  /var/www/example.com/public;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;

        # With php-fpm:
        fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        # With php-cgi:
        # fastcgi_pass 127.0.0.1:9000;
    }

    error_page 404 /index.php;

    # deny access to hidden files such as .htaccess
    location ~ /\. {
        deny all;
    }
}

Hosting with Vagrant

Virtualization is an effective way to test your webapp in the environment you plan to deploy on, even if you develop on a different one. Even if you are using the same platform for both, virtualization provides an isolated environment for testing.

The codebase comes with a VagrantFile.dist, that can be copied to VagrantFile and tailored for your system, for instance enabling access to specific database or caching engines.

Setting Up

It assumes that you have installed VirtualBox and Vagrant for your platform.

The Vagrant configuration file assumes you have set up a ubuntu/bionic64 Vagrant box on your system:

vagrant box add ubuntu/bionic64

Testing

Once set up, you can then launch your webapp inside a VM, with the command:

vagrant up

Your webapp will be accessible at http://localhost:8080, with the code coverage report for your build at http://localhost:8081 and the user guide for it at http://localhost:8082.

Bootstrapping the App

In some scenarios you will want to load the framework without actually running the whole application. This is particularly useful for unit testing your project, but may also be handy for using third-party tools to analyze and modify your code. The framework comes with a separate bootstrap script specifically for this scenario: system/Test/bootstrap.php.

Most of the paths to your project are defined during the bootstrap process. You may use pre-defined constants to override these, but when using the defaults be sure that your paths align with the expected directory structure for your installation method.

News

IMG
Samsung Galaxy Z Fold3
News 05 Sep-2021

Samsung Galaxy Z Fold3

 

How is the Samsung Galaxy Z Fold3 different?

Now, this is a question quite a few people have asked. But the answer is simple. It is better, it is thinner and lighter. In other words, the third version of the Fold is much more refined and visibly so. The hinge, which earlier used to look like an appendage, is now seamlessly integrated into the design. The phone, when closed, fits much better in your hand. The folded Fold 3 also feels more like a Samsung galaxy device now that the front screen is almost edge-to-edge.

How good is the in-screen camera design?

The big design change is when you open the Fold3 and use the larger screen. The front-facing camera here is behind the screen and eliminates the need for a notch or hole. But you can see the small round when you are on a white screen though it will not hamper your experience in any way. And when you switch to the front camera this suddenly comes to life with a spark around the screen — quite a spectacle and something you will enjoy every time. Also, this new tweak makes the larger screen of the Fold3 much more usable.

Is the crease on the folded screen gone now?

The crease is very much there, though subdued. After having seen many foldable over the past couple of years I am not sure the crease will ever go away. That would have to be a wonder of physics if at all. Companies will however try to make them less visible though. On the Z Fold3, the crease is visible more when you are on a white screen, like when checking Gmail. On colourful screens, it sort of vanishes at least stays out of sight.

How good is the camera?

When someone asks me this, I want to respond by asking: “Does it really matter in this phone?”. But anyway, people do tend to take the camera seriously on all their phones. The Fold3 is a flagship and the camera is not something we should really worry about. The rear camera for me is close to what the S series does and will not disappoint you. However, it will surely leave you confused — do you click photos with the phone closed or open? Whatever you do, the photos to come out to be good no matter the conditions.

 

NETWORK Technology GSM / CDMA / HSPA / EVDO / LTE / 5G
LAUNCH Announced 2021, August 11
Status Available. Released 2021, August 27
BODY Dimensions Unfolded: 158.2 x 128.1 x 6.4 mm
Folded: 158.2 x 67.1 x 14.4-16 mm
Weight 271 g (9.56 oz)
Build Glass front (Gorilla Glass Victus) (folded), plastic front (unfolded), glass back (Gorilla Glass Victus), aluminum frame
SIM Nano-SIM and eSIM
  IPX8 water resistant (up to 1.5m for 30 mins)
Stylus support
DISPLAY Type Foldable Dynamic AMOLED 2X, 120Hz, HDR10+, 1200 nits (peak)
Size 7.6 inches, 179.9 cm2 (~88.8% screen-to-body ratio)
Resolution 1768 x 2208 pixels (~374 ppi density)
  Cover display:
Dynamic AMOLED 2X, 120Hz, Corning Gorilla Glass Victus
6.2 inches, 832 x 2268 pixels, 25:9 ratio
PLATFORM OS Android 11, One UI 3.1.1
Chipset Qualcomm SM8350 Snapdragon 888 5G (5 nm)
CPU Octa-core (1x2.84 GHz Kryo 680 & 3x2.42 GHz Kryo 680 & 4x1.80 GHz Kryo 680)
GPU Adreno 660
MEMORY Card slot No
Internal 256GB 12GB RAM, 512GB 12GB RAM
  UFS 3.1
MAIN CAMERA Triple 12 MP, f/1.8, 26mm (wide), 1/1.76", 1.8µm, Dual Pixel PDAF, OIS
12 MP, f/2.4, 52mm (telephoto), 1/3.6", 1.0µm, PDAF, OIS, 2x optical zoom
12 MP, f/2.2, 123˚, 12mm (ultrawide), 1.12µm
Features LED flash, HDR, panorama
Video 4K@60fps, 1080p@60/240fps (gyro-EIS), 720p@960fps (gyro-EIS), HDR10+
SELFIE CAMERA Single 4 MP, f/1.8, 2.0µm, under display
Cover camera:
10 MP, f/2.2, 26mm (wide), 1/3", 1.22µm
Features HDR
Video 4K@30fps, 1080p@30fps, gyro-EIS
SOUND Loudspeaker Yes, with stereo speakers
3.5mm jack No
  32-bit/384kHz audio
Tuned by AKG
COMMS WLAN Wi-Fi 802.11 a/b/g/n/ac/6e, dual-band, Wi-Fi Direct, hotspot
Bluetooth 5.2, A2DP, LE, aptX HD
GPS Yes, with A-GPS, GLONASS, GALILEO, BDS
NFC Yes
Radio No
USB USB Type-C 3.2
FEATURES Sensors Fingerprint (side-mounted), accelerometer, gyro, proximity, compass, barometer
  Bixby natural language commands and dictation
Samsung DeX (desktop experience support)
Samsung Pay (Visa, MasterCard certified)
Ultra Wideband (UWB) support
BATTERY Type Li-Po 4400 mAh, non-removable
Charging Fast charging 25W
Fast wireless charging 11W
Reverse wireless charging 4.5W
MISC Colors Phantom Black, Phantom Silver, Phantom Green
TESTS Performance AnTuTu: 635918 (v8), 752218 (v9)
GeekBench: 12719 (v4.4), 3239 (v5.1)
GFXBench: 38fps (ES 3.1 onscreen)
Camera Photo / Video
Loudspeaker -25.6 LUFS (Very good)
Battery life
Endurance rating 75h

 

 

 

IMG
iPhone 13 series is expected to launch in September
News

iPhone 13 series is expected to launch in September year and expected to come with Wi-Fi 6E support for the 6GHz band and increased range, a new report says. The latest Apple smartphone is expected to come with upgraded cameras, particularly the wide-angle lens, and expanded mmWave support to more regions.

A DigiTimes report cites industry sources to say Apple will incorporate Wi-Fi 6E technology into its new iPhones this year, and the technology is expected to become a standard feature of both iOS and Android smartphones in 2022.

This will lead to significant gains for Taiwan's GaAs IC foundries Win Semiconductors, Advanced Wireless Semiconductor Company (AWSC), and GaAs epi-wafer supplier Visual Photonics Epitaxy Company (VPEC).

Apple introduced Wi-Fi 6 with the iPhone 11, which significantly improved speeds and security than the previous generation Wi-Fi 5 protocol. Wi-Fi 6E is considered as a slight upgrade in comparison as t only adds minimal 6GHz band support. This will result in increased bandwidth and less interference for devices that support Wi-Fi 6E.

The report adds that the three companies mentioned above will also see third quarter revenue increase further because of VCSEL chips demand as iPhones continue to adopt 3D Face ID sensors for general models and ToF LiDAR scanners for Pro series.

 

IMG
Facebook removes malicious accounts, groups and pages
News

Facebook has suspended 5,381 malicious accounts, Groups and Pages from its main network and Instagram, according to a report by IANS. The social media platform had removed eight networks from seven countries. The majority of these campaigns targeted people in their own countries.

The cited source reported that around 2,784 Facebook accounts, 206 Instagram accounts, 2,249 Pages and 142 Groups were removed in the month of June. In Iraq and Iran, Facebook suspended 675 Facebook accounts, 16 Pages, and 10 Instagram accounts that reportedly targeted audiences in Iraq and were linked to Al-Maaref Radio in Iraq and Alborz Analysis and Development, an IT firm in Tehran.

 

 

“We found this activity as part of our internal investigation into suspected coordinated inauthentic behaviour in the region,” Facebook said while commenting on the same.

In Mexico, Facebook removed 1,621 Facebook accounts, 1,795 Pages, 75 Groups, and 93 Instagram accounts that focused on the state of Campeche and were linked to people in that state. It included individuals that were working for Worgcorp, a political strategy and public relations firm in Mexico.

“We found this activity as part of our internal investigation into suspected coordinated inauthentic behaviour in the region and removed it ahead of the Mexican elections,” Facebook said.

“When we find domestic, non-government campaigns that include groups of accounts and Pages seeking to mislead people about who they are and what they are doing while relying on fake accounts, we remove both inauthentic and authentic accounts, Pages and Groups directly involved in this activity,” Facebook added.

 

Written with inputs from IANS

Course

IMG
CCNA2 Chapter 1
Course - 12 Jan-2021

 

Exploring the Network

§Explain how multiple networks are used in everyday life.

§Explain the topologies and devices used in a small to medium-sized
business network.

§Explain the basic characteristics of a network that supports
communication in a small to medium-sized business.

§Explain trends in networking that will affect the use of networks in
small to medium-sized businesses.
 
 
Thank you
Chapter 2 will be soon

 

Projects