Install New Phalcon PHP (v 4) in Windows 10 64 bit and Laragon

Since its v4 release I don’t have time to test this version in my windows 10 box.

Today is the right time because I don’t know, I want to hehehe.

I already have phalcon 3.4.5 installed and related phalcon dev tools.

phalcon info

Phalcon DevTools (3.4.0)

Environment:
OS: Windows NT DESKTOP-O8J2929 10.0 build 18362 (Windows 10) AMD64
PHP Version: 7.2.26
PHP SAPI: cli
PHP Bin: C:\laragon\bin\php\php-7.2.26-nts-Win32-VC15-x64\php.exe
PHP Extension Dir: C:\php\ext
PHP Bin Dir: C:\php
Loaded PHP config: C:\laragon\bin\php\php-7.2.26-nts-Win32-VC15-x64\php.ini
Versions:
Phalcon DevTools Version: 3.4.0
Phalcon Version: 3.4.5
AdminLTE Version: 2.3.6

PHP 7.4.4 nts already in place

C:\laragon\www
? php -m | grep phalcon
Warning: Cannot load module ‘phalcon’ because required module ‘psr’ is not loaded in Unknown on line 0

C:\laragon\www
? php -m | grep phalcon
phalcon

Choose DLL version

Choose proper nts for my 64 bit machine

Enable phalcon and psr extension from Extensions menu and restart laragon

nice, phalcon 4.0.6 installed successfully

Time for phalcon devtools

Preparation before cloning

mv phalcondevtools phalcondevtools3

git clone https://github.com/phalcon/phalcon-devtools.git
Cloning into ‘phalcon-devtools’…
remote: Enumerating objects: 27110, done.
remote: Total 27110 (delta 0), reused 0 (delta 0), pack-reused 27110
Receiving objects: 100% (27110/27110), 19.44 MiB | 1.65 MiB/s, done.
Resolving deltas: 100% (14463/14463), done.

Rename

mv phalcon-devtools phalcondevtools4

mv phalcondevtools3 phalcondevtools

At this moment I have two folder :

phalcondevtools -> for phalcon 3

phalcondevtools4 -> for phalcon 4

Install phalcon dev tools 4′

cd phalcondevtools4

composer install

Check it now

C:\phalcondevtools4 (master)
? phalcon info

Phalcon DevTools (4.0.3)

Environment:
OS: Windows NT DESKTOP-O8J2929 10.0 build 18362 (Windows 10) AMD64
PHP Version: 7.4.4
PHP SAPI: cli
PHP Bin: C:\laragon\bin\php\php-7.4.4-nts-Win32-vc15-x64\php.exe
PHP Extension Dir: C:\php\ext
PHP Bin Dir: C:\php
Loaded PHP config: C:\laragon\bin\php\php-7.4.4-nts-Win32-vc15-x64\php.ini
Versions:
Phalcon DevTools Version: 4.0.3
Phalcon Version: 4.0.6
AdminLTE Version: 2.3.6

Test call from absolutee path

c:\phalcondevtools4\phalcon

Phalcon DevTools (4.0.3)

Available commands:
info (alias of: i)
commands (alias of: list, enumerate)
controller (alias of: create-controller)
module (alias of: create-module)
model (alias of: create-model)
all-models (alias of: create-all-models)
project (alias of: create-project)
scaffold (alias of: create-scaffold)
migration (alias of: create-migration)
webtools (alias of: create-webtools)
serve (alias of: server)
console (alias of: shell, psysh)

Great, now its time for symbolic link

Well, at the moment symbolic link is not work so I use absolute path to create phalcon 4 project.

in Blog | 375 Words

Compile Phalcon Extension on Centminmod

Wow, almost a year I didn’t touch this blog. At least this blog still have visitor from nowhere 🙂

Ok, today I have challenge to install phalcon php extension (at the moment the version is 3.4.2). The vps server already has centminmod installed using latest version of CentOS 7.

Since the server is critical so I decide to use other vps server (get free $25 in credit for new user here) to get the recipe and share it here for others that might need it.

Lets get start!

Update CentOS

# yum update

Check current php version

# php -v

PHP 7.0.33 (cli) (built: Feb 16 2019 10:38:06) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

Yes, this legacy app run on php 7.0.33

Compile Phalcon php

# git clone --branch v3.4.2 --depth=1 "git://github.com/phalcon/cphalcon.git"

# cd cphalcon/build/

# ./install

Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
appending configuration tag “CXX” to libtool
mkdir .libs
gcc -I. -I/root/cphalcon/build/php7/64bits -DPHP_ATOM_INC -I/root/cphalcon/build/php7/64bits/include -I/root/cphalcon/build/php7/64bits/main -I/root/cphalcon/build/php7/64bits -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DPHALCON_RELEASE -DHAVE_CONFIG_H -march=native -mtune=native -O2 -fomit-frame-pointer -c /root/cphalcon/build/php7/64bits/phalcon.zep.c -fPIC -DPIC -o .libs/phalcon.o

gcc -shared .libs/phalcon.o -march=native -mtune=native -Wl,-soname -Wl,phalcon.so -o .libs/phalcon.so
creating phalcon.la
(cd .libs && rm -f phalcon.la && ln -s ../phalcon.la phalcon.la)
cp ./.libs/phalcon.so /root/cphalcon/build/php7/64bits/modules/phalcon.so
cp ./.libs/phalcon.lai /root/cphalcon/build/php7/64bits/modules/phalcon.la
PATH=”$PATH:/sbin” ldconfig -n /root/cphalcon/build/php7/64bits/modules
———————————————————————-
Libraries have been installed in:
/root/cphalcon/build/php7/64bits/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

Build complete.
Don’t forget to run ‘make test’.

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20151012/
Installing header files: /usr/local/include/php/

Thanks for compiling Phalcon!
Build succeed: Please restart your web server to complete the installation

Enable phalcon extension

# nano /etc/centminmod/php.d/phalcon.ini

fill with this line :

extension=phalcon.so

save the file and restart

# nprestart

Check if phalcon extension installed

echo ‘<?php phpinfo();?>’ > /usr/local/nginx/html/info2.php

then access it with browser

or using command line

# php -m | grep phalcon

Handling rewrite problem

“Mod-Rewrite is not enabled

Please enable rewrite module on your web server to continue”

# nano /usr/local/nginx/conf/conf.d/learn.digitalfusi.com.ssl.conf

Change these sections :

1. root /home/nginx/domains/url/public/public;
2. try_files $uri $uri/ /index.php?_url=$uri&$args;

save.

Update 1 :

section 2 need to update as this :

try_files $uri $uri/ @rewrite;

and make new section for @rewrite :

location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
} #rewrite

Update 2 :

Handling error message :

“warning: Remote branch v3.4.3 not found in upstream origin, using HEAD instead”

wget -c https://github.com/phalcon/cphalcon/archive/v3.4.3.tar.gz

tar xvzf v3.4.3.tar.gz

cd cphalcon-3.4.3/build/

./install

Try if rewrite rule work

Edit controller file

# nano /home/nginx/domains/url/public/app/controllers/IndexController.php

Modify the content to this

<?php

class IndexController extends ControllerBase
{

public function indexAction()
{

}

public function testAction($id1,$id2,$id3)

{
echo ‘really nice bro ‘.$id1.’ var 2 :’.$id2.’ var 3 : ‘.$id3;
}
}

save the file.

Access the address from browser

https://url/index/test/d/e/f

and the output will be

really nice bro d var 2 :e var 3 : f

Great, since the value of d,e and f printed correctly then rewrite rule work perfectly.

Note :

  • I upload sample project inside public folder so for root (document root) I change it to public/public.
  • url in this note is depend on you. It might be tld os subdomain
  • I enable https by default so I only deal with ssl.conf file
  • webtools only available from localhost, enable it from cmd -> phalcon project projectname –enable-webtools
in Blog | 819 Words

Free $20 for DevOps Class – openbsd, freebsd, dragonflybsd and netbsd vps

Update : The offer seem no longer available.

I have to prepare for new class that required vps access. The class will teach unix based system like openbsd, freebsd, dragonfly bsd plus netbsd in 12 meets.

This class will be basic for devops but most important thing for me is my student can get full environment in every OS. Vps came to my mind and this March 2017 is really great since Vultr announce great news :

They double everything and they also provide ‘sanbox plan’ for beginner.

In nutshell you’ll get 1GB memory and 25Gb space vps on the OS you choose. SSD speed also superb :

dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync
16384+0 records in
16384+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 3.87756 s, 277 MB/s

For limited time Vultr offer free $20 that you can use for many things;

  • Set git server using gitlab.
  • Set up aws compatible cloud with minio
  • Testing zfs latest FreeBSD 12 vs Hammer in dragonflybsd
  • Tes mysql replicate while setting master in Germany Vps and mysql slave in Paris or Amsterdam.

Long time ago I’ll need $10 server to achieve that but now I just need $5 vps server /mo to get 1GB server which is awesome 🙂

I just spread the news to let others know and grab your free $20 by using this link.

Long live the queen!

in Blog | 221 Words

Install Laravel Valet on macOS Sierra

Just quick note for myself when try Laravel Valet on macOS Sierra (10.12.2)

Install  homebrew (if not installed) :

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

Install PHP 7.1

Libpng

brew link libpng

Linking /usr/local/Cellar/libpng/1.6.28… 18 symlinks created

brew install homebrew/php/php71

test :

php -v

PHP 7.1.0 (cli) (built: Dec  2 2016 11:32:42) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies

Install Composer

brew install composer

Install Valet

composer global require laravel/valet
cd
nano .bash_profile

Add this line :

export PATH=$PATH:~/.composer/vendor/bin

save.

source .bash_profile
echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/alamsyahrasyid/.composer/vendor/bin

valet install

Password:
[nginx] is not installed, installing it now via Brew… ?
[dnsmasq] is not installed, installing it now via Brew… ?

Valet installed successfully!

Start valet

valet start

Valet services have been started.

Install mysql

brew install mariadb
brew services start mariadb

 

in Blog | 163 Words

How to install virtual Ftp hosting with PureFTP on FreeBSD 10 : Part 2 – TLS & Unix Auth

In 1st part of this post I have very general setting for pure-ftp configured. In this post we’ll explore about testing functionality of this ftp server using simple auth plus how configure TLS section.

To test the server I need to add user. I used to use sysinstall for this purpose but since sysinstall no longer available on FreeBSD then I use bsdconfig.

Introduce bsdconfig

From bsconfig manual :

bsdconfig is used to set up many system configuration settings, both for
new systems, as well as changing configuration settings of existing systems.

bsdconfig optionally takes    a command as an    argument.  If invoked with no arguments,
it will bring up an interactive    menu listing the available modules.

I like gui version so I type bsdconfig or you can use full path : /usr/sbin/bsdconfig

If not available you can install it.

From ports

# /usr/ports/sysutils/bsdconfig && make install

From pkg

# pkg install bsdconfig

For pure-ftp purpose I need bsdconfig for add new user :

#bsdconfig

Choose “Login/Group Management”

bsdconfig as sysinstall replacement

Continue reading

in Blog | 800 Words