404 error when calling REST api (Phalcon)

Standard

XMLHttpRequest cannot load http://ajax.example.com/like/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://blog.example.com' is therefore not allowed access.

Solution:

Set htaccess like this:

# Always set these headers.
Header always setAccess-Control-Allow-Origin"*"
Header always setAccess-Control-Allow-Methods"POST, GET, OPTIONS, DELETE, PUT"
Header always setAccess-Control-Max-Age"1000"
Header always setAccess-Control-Allow-Headers"x-requested-with, Content-Type, origin, authorization, accept, client-security-token"

 

Install Dev-Tools Phalcon

Standard

First:

git clone https://github.com/phalcon/phalcon-devtools.git

Installing via Composer

Install composer in a common location or in your project:

curl -s http://getcomposer.org/installer | php

Create the composer.json file as follows:

{
    "require": {
        "phalcon/devtools": "dev-master"
    }
}

If you are still using Phalcon 1.3.x, create a composer.json with the following instead:

{
    "require": {
        "phalcon/devtools": "1.3.*@dev"
    }
}

Run the composer installer:

php composer.phar install

Create a symbolic link to the phalcon.php script:

ln -s ~/devtools/phalcon.php /usr/bin/phalcon
chmod ugo+x /usr/bin/phalcon

Sample Project mongodb with phalcon Framework

Standard

Selain kemampuannya untuk memetakan tabel dalam database relasional, Phalcon dapat memetakan dokumen dari database NoSQL. ODM menawarkan fungsi CRUD, peristiwa, validasi antara layanan lainnya.

Karena tidak adanya query SQL dan perencana, database NoSQL dapat melihat perbaikan nyata dalam kinerja menggunakan pendekatan Phalcon. Selain itu, tidak ada bangunan SQL mengurangi kemungkinan suntikan SQL.

Untuk terkoneksi dengan mongoDB

Continue reading

dev-tools phalcon

Standard

Sample command:

$ phalcon commands

Phalcon DevTools (1.2.3)

Available commands:
  commands (alias of: list, enumerate)
  controller (alias of: create-controller)
  model (alias of: create-model)
  all-models (alias of: create-all-models)
  project (alias of: create-project)
  scaffold
  migration
  webtools
$ phalcon create-project store

Continue reading

Instalasi Phalcon Framework

Standard

Instalasi Phalcon Framework di Ubuntu 14.04
1. Pastikan koneksi internet sudah berjalan dengan baik.

2. Instalasi software yang dibutuhkan:

sudo apt-get install php5-dev libpcre3-dev gcc make php5-mysql git-core
3. Cloning, kompilasi dan install:

git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install
4. Buat file /etc/php5/mods-available/phalcon.ini. Isi dengan

; configuration for php phalcon module
; priority=30
extension=phalcon.so
5. Jika menggunakan Apache + PHP, maka bangun symlink pada folder /etc/php5/apache2/conf.d:

cd /etc/php5/apache2/conf.d/
sudo ln -s ../../mods-available/phalcon.ini 30-phalcon.ini
sudo service apache2 restart
6. Untuk mencek apakah extension phalcon sudah di-load dengan benar, buat file /var/www/html/info.php, dengan isi:

<?php phpinfo(); ?>

Selamat mencoba.

Referensi

http://docs.phalconphp.com/en/latest/reference/install.html#linux-solaris