Showing posts with label Symfony. Show all posts
Showing posts with label Symfony. Show all posts

Friday, 21 June 2019

Best leading PHP frameworks in 2019

The top 10 PHP frameworks

Here’s a list of the best PHP frameworks, based on popularity and ability to facilitate application development.

  1. Laravel
  2. Symfony
  3. CodeIgniter
  4. Zend
  5. CakePHP
  6. FuelPHP
  7. Yii 2
  8. Phalcon
  9. Slim
  10. PHPixie


1. Laravel


If frameworks were people, Laravel would probably be the king. If you want to code beautiful designs, you’re looking for Laravel since it’s positioned as the go-to PHP framework for web artisans.
The reason for its wide popularity boils down to ease of use and virtually no learning curve. And despite that, it’s a framework developer use for some serious work. So it may seem like a simple tool at first, but it’s a beast when it comes to producing concrete work.

2. Symfony

When it comes to developing large-scale enterprise projects, Symfony makes a perfect choice amongst the PHP frameworks. Its ecosystem is a huge one, with a big set of reusable components and an active community of developers. The components serve the purpose of completing diverse tasks such as for creation, the configuration of objects, authentication, routing, templating, and much more. These components are being used to power up projects such as Drupal, Laravel, PHPBB, PIWIk, and OROCRM.

3. CodeIgniter

CodeIgniter is one of the oldest frameworks but is simple and powerful. It can easily be installed and requires minimal user configuration. It works perfectly on almost all shared and dedicated hosting platforms. CodeIgniter isn’t entirely based on the MVC framework. Models and Views are optional, but Controller classes are a must. Another strength of CodeIgniter is speed. It runs faster with database tasks in comparison to other frameworks. CodeIgniter is well documented and a good framework to start with for PHP beginners.

Monday, 14 April 2014

Symfony http to https

Secure SSL(https) Redirect Filter for Symfony
please follow the steps given below to put up specific page to https or secure url:
1) First add the following settings to your app.yml file:
all:
  ssl:
    insecure_host:    www.avidindiainc.com/blog
    secure_host:      www.avidindiainc.com    
    secure_actions:
      - { module: shop, action: register }
      - { module: shop, action: checkout }
      - { module: register, action: updateCardDetails }

2) Next we add our filter code to lib/sslFilter.class.php (apps/[application name]/lib):

/**
 * Filter for redirecting to SSL for the pages that need it
 *
 * @author Sachin Makwana <sachin@avidindiainc.com>
 * @version 2
 */
class sslFilter extends sfFilter
{
  /**
   * Execute filter
   *
   * @param FilterChain $filterChain The symfony filter chain
   */
  public function execute ($filterChain)
  {
    // Only execute this filter once
    if ($this->isFirstCall() && SF_ENVIRONMENT != 'dev') {
      // Array of modules/actions that require move to SSL
      $ssl_actions = sfConfig::get('app_ssl_secure_actions');

      if (empty($_SERVER['HTTPS']) && count($_POST) < 1) {

        // We're not using SSL and not POSTing data - check if we should be using SSL
        foreach ($ssl_actions as $action) {
          if ($this->getContext()->getModuleName() == $action['module'] && $this->getContext()->getActionName() == $action['action']) {
            $new_url = sprintf('https://%s%s', sfConfig::get('app_ssl_secure_host'), $_SERVER['REQUEST_URI']);
            header('Location: ' . $new_url);
            exit;
          }
        }

        // Using secure host when not required - not good
        if ($_SERVER['HTTP_HOST'] == sfConfig::get('app_ssl_secure_host')) {
          $new_url = sprintf('http://%s%s', sfConfig::get('app_ssl_insecure_host'), $_SERVER['REQUEST_URI']);
          header('Location: ' . $new_url);
          exit;
        }
      } elseif (!empty($_SERVER['HTTPS']) && count($_POST) < 1) {

        // We're using SSL and not posting data
        $dont_redirect = false;
        foreach ($ssl_actions as $action) {
          if ($this->getContext()->getModuleName() == $action['module'] && $this->getContext()->getActionName() == $action['action']) {
            $dont_redirect = true;
          }
        }
        if ($dont_redirect == false) {
          // Redirect
          $new_url = sprintf('http://%s%s', sfConfig::get('app_ssl_insecure_host'), $_SERVER['REQUEST_URI']);
          header('Location: ' . $new_url);
          exit;
        }
      }
    }
    // Next filter
    $filterChain->execute();
  }
}

3) Finally, enable your sslFilter in the application’s config/filters.yml configuration file:

sslFilter:
  class:  sslFilter

Symfony Generator Configuration

Symfony Generator Configuration

Remove Filter , New , Edit ,Delete batch action Using generator.yml

    config:
      actions: ~
      fields:  
        ip:    { label: IP Address ,is_link: false}
        status: {type: Boolean}
      list:    
        max_per_page: 4
        sort: [status, desc]
        display: [name,ts,country,city,browser,status]
        fields:
          ts: { date_format:'dd-MMM-yyyy hh:mm:ss a' }
        batch_actions: {}
        object_actions: {}
        actions: { }
      filter:
        class: false
      form:   ~
      edit:   ~
      new:    ~

Block some field for admin only 
fields:

 ip:      { credentials: [admin] }


Date format

http://blog.rajatpandit.com/2009/01/28/datehelper-date_format-in-symfony/


http://www.symfonyreference.com/generator-yml

Symfony customise widget from action class

Symfony customise widget from action class


$formBasic->setWidget('email', new sfWidgetFormInputHidden()); 

$formBasic->setDefault('email',$userData['email']);


Symfony generate admin module action class


symfony doctrine:build --all-classes


symfony doctrine:generate-admin admin Winner --module=winners

Monday, 3 February 2014

DateHelper (date_format) in symfony

DateHelper (date_format) in symfony


DateHelper has a particular function format_date which is quite good for formatting dates, esp that come straight from the propel object. However looking at the Helper file DateHelper.php you cant really tell what sort of formats does it accept and no it doesnt take the standard PHP date formats.
Digging a little further I found the details in another file sfDateFormat.class.php and as the class states.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
   switch ($pattern)
    {
      case 'd':
        return $this->formatInfo->ShortDatePattern;
        break;
      case 'D':
        return $this->formatInfo->LongDatePattern;
        break;
      case 'p':
        return $this->formatInfo->MediumDatePattern;
        break;
      case 'P':
        return $this->formatInfo->FullDatePattern;
        break;        
      case 't':
        return $this->formatInfo->ShortTimePattern;
        break;
      case 'T':
        return $this->formatInfo->LongTimePattern;
        break;
      case 'q':
        return $this->formatInfo->MediumTimePattern;
        break;
      case 'Q':
        return $this->formatInfo->FullTimePattern;
        break;
      case 'f':
        return $this->formatInfo->formatDateTime($this->formatInfo->LongDatePattern, $this->formatInfo->ShortTimePattern);
        break;
      case 'F':
        return $this->formatInfo->formatDateTime($this->formatInfo->LongDatePattern, $this->formatInfo->LongTimePattern);
        break;
      case 'g':
        return $this->formatInfo->formatDateTime($this->formatInfo->ShortDatePattern, $this->formatInfo->ShortTimePattern);
        break;
      case 'G':
        return $this->formatInfo->formatDateTime($this->formatInfo->ShortDatePattern, $this->formatInfo->LongTimePattern);
        break;
      case 'i':
        return 'yyyy-MM-dd';
        break;
      case 'I':
        return 'yyyy-MM-dd HH:mm:ss';
        break;
      case 'M':
      case 'm':
        return 'MMMM dd';
        break;
      case 'R':
      case 'r':
        return 'EEE, dd MMM yyyy HH:mm:ss';
        break;
      case 's':
        return 'yyyy-MM-ddTHH:mm:ss';
        break;
      case 'u':
        return 'yyyy-MM-dd HH:mm:ss z';
        break;
      case 'U':
        return 'EEEE dd MMMM yyyy HH:mm:ss';
        break;
      case 'Y':
      case 'y':
        return 'yyyy MMMM';
        break;
      default :
        return $pattern;
    }