Propel e portali – appunti utili… a me

Installazione Propel

just create a new composer.json file at the root of your project’s directory with the following content:

{
"require": {
"propel/propel": "~2.0@dev"
}
}

wget http://getcomposer.org/composer.phar

php composer.phar install

Per testarlo:

cd myproject
e lancia
vendor/bin/propel
export PATH=$PATH:/path/to/vendor/bin/
cd mkdir propel
mkdir propel/class
propel init
propel model:build
vim composer.json
{
"require": {
"propel/propel": "~2.0@dev"
},
"autoload": {
"classmap": ["propel/class/"]
}
}

php composer.phar dump-autoload

propel config:convert

nei file php:

require_once 'include.inc.php';
// setup the autoloading
require_once 'vendor/autoload.php';
//require_once 'vendor/autoload.php';
// setup Propel
require_once 'generated-conf/config.php';

e poi:

 $avviso->setDtAvviso("2013-12-11");
echo $avviso->getAvviso();
var_dump($avviso->getDtAvviso());
$d1=new DateTime("2012-07-08 11:14:15.638276");
var_dump($d1);
echo $d1->format('Y-m-d H:i');
echo $avviso->getDtAvviso()->format('Y-m-d H:i');
$newDate = $avviso->getDtAvviso();
$newDate = $newDate->format('Y-m-d H:i:s'); // for example
$avviso->save()
?>

[modifica]
Propel – Installazione con reverse

just create a new composer.json file at the root of your project’s directory with the following content:

{
"require": {
"propel/propel": "~2.0@dev"
}
}

wget http://getcomposer.org/composer.phar

php composer.phar install

Per testarlo:

cd myproject
e lancia
vendor/bin/propel
export PATH=$PATH:/path/to/vendor/bin/
cd mkdir propel
mkdir propel/class
genera il file propel.yml :
Attenzione che deve essere INDENTATO!!!!
propel:
  general:
      project: bandi_concorsi
      version: 0.4

  paths:
      projectDir:  /var/www/vhosts/bandi_concorsi
      schemaDir: /var/www/vhosts/bandi_concorsi/propel
      phpDir: /var/www/vhosts/bandi_concorsi/propel/class
      phpConfDir: /var/www/vhosts/bandi_concorsi/propel
      # Directory in which your composer.json resides
#      composerDir: {empty}

## All Database settings ##
  database:
      connections:
          default:
              adapter: mysql
              dsn: mysql:host=localhost;dbname=bandi_concorsi
              user: root
              password:
              settings:
                  charset: utf8

          bandi_concorsi:
              adapter: mysql
              dsn: "mysql:host=localhost;dbname=bandi_concorsi"
              user: root
              password:
              settings:
                  charset: utf8

          albopretorio:
              adapter: mysql
              dsn: "mysql:host=192.168.0.20;dbname=albopretorio"
              user: user_db
              password: pass_db_pass
              attributes:

          protocollo:
              adapter: pgsql
              dsn: "pgsql://protocolloro:protocolloro@192.168.0.23:5433/protocollo"
              user: protocolloro
              password: protocolloro
              attributes:
propel reverse --output-dir="./propel"
propel model:build
vim composer.json
{
"require": {
"propel/propel": "~2.0@dev"
},
"autoload": {
"classmap": ["propel/class/"]
}
}

php composer.phar dump-autoload

propel config:convert

nei file php:

require_once 'include.inc.php';
// setup the autoloading
require_once 'vendor/autoload.php';
//require_once 'vendor/autoload.php';
// setup Propel
require_once 'propel/config.php';

e poi:

 $avviso->setDtAvviso("2013-12-11");
echo $avviso->getAvviso();
var_dump($avviso->getDtAvviso());
$d1=new DateTime("2012-07-08 11:14:15.638276");
var_dump($d1);
echo $d1->format('Y-m-d H:i');
echo $avviso->getDtAvviso()->format('Y-m-d H:i');
$newDate = $avviso->getDtAvviso();
$newDate = $newDate->format('Y-m-d H:i:s'); // for example
$avviso->save()
?>

Installare php 5.4 su CentOs 6.x

Thanks to
http://sharadchhetri.com/2015/04/04/install-php-5-4-on-centos-6-with-yum-command/

Step 1. Install SCL repo only by hitting below given command.

yum install centos-release-SCL

Step 2. Install php 5.4 version on system now.

yum install php54

To install specific package, package name should be known. Hence, to get the list of available package list from SCL repo run below given command.

yum list|grep php

Step 3. Activate the PHP 5.4 on system.
NOTE: If you run below given command directly from terminal then on next login you will not find PHP 5.4 path.

source /opt/rh/php54/enable

Basically the above command, make PHP 5.4 executable path and environment available to current login user.

To make PHP 5.4 available to all user , we have to add line source /opt/rh/php54/enable inside file called /etc/profile. Now activate without logout by running command.

source /etc/profile

Or in case, if you only want php 5.4 available to specific user then just only edit .bashrc or .bash_profile file from User’s home directory. And add line source /opt/rh/php54/enable .

Step 4. Now check the php version

php -v

Below given is reference from our system.

[root@localhost ~]# php -v
PHP 5.4.16 (cli) (built: Nov 19 2014 08:05:17)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
[root@localhost ~]#
IMPORTANT NOTE : The PHP 5.4 package actually installed in /opt/rh directory.

ATTENZIONE!!!! Abilitazione x virtualhost

thanks to: http://www.ilsistemista.net/index.php/linux-a-unix/45-joomla-3-3-centos-6-and-php-version-putting-all-together.html?start=1

Step n.1: enable the SCL repo and install PHP 5.4

yum install -y centos-release-SCL.x86_64
yum install -y php54.x86_64 php54-php-mysqlnd

Step n.2: create a PHP wrapper script in /var/www/cgi-bin/php54-wrapper

#!/bin/bash
source /opt/rh/php54/enable
exec php-cgi $1

Then give it the appropriate permissions and restore the selinux context:

restorecon -RF /var/www/cgi-bin/php54-wrapper
chown apache:apache /var/www/cgi-bin/php54-wrapper
chmod ugo-rwx /var/www/cgi-bin/php54-wrapper
chmod ug+rx /var/www/cgi-bin/php54-wrapper

Step n.3: configure the appropiate VirtualHost to use the new PHP version via the CGI interface

AddHandler php-cgi .php
Action php-cgi /cgi-bin/php54-wrapper
Options +ExecCGI

This configuration instruct Apache to use the new PHP 5.4 version for this and only this Virtualhost, leaving all others configuration intact: other Virtualhosts will continue to use PHP 5.3 version via mod_php.

 

Nota:

se smette di funzionare occorre rinominare il file

/etc/httpd/conf.d/php54-php.conf

in

/etc/httpd/conf.d/php54-php.conf.vhosts