2012年9月6日 星期四

phpmyadmin xampp new security concept


phpmyadmin xampp new security concept

http://www.apachefriends.org/f/viewtopic.php?p=196736

http://www.apachefriends.org/f/viewtopic.php?f=17&t=50902&p=196185#p196185

摘錄:
In a terminal:
Code: Select all
sudo gedit /opt/lampp/etc/extra/httpd-xampp.conf


In gedit, Find:
<Directory "/opt/lampp/phpmyadmin">

And add the line to the <Directory>:
Require all granted

After this, the section reads:
Code: Select all
<Directory "/opt/lampp/phpmyadmin">
    AllowOverride AuthConfig Limit
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

新發現


關鍵字:
mysql schema to orm class

網址:
http://www.codediesel.com/php/automatically-create-php-classes-from-mysql/

在網頁中發現:
table2class

載點:
https://github.com/stevenflesch/table2class/zipball/master

自己下載來玩玩吧

mysql database schema(file OR export OR backup)


mysql database schema(file OR export OR backup)

http://www.dzone.com/snippets/export-your-mysql-database

mysqldump --no-data --tables -u YOUR_USER_NAME -p DATABASE_YOU_WANT_SCRIPTED >> FILENAME.sql
example:
1.mysqldump --no-data --tables -u larry -p contacts >> contacts.sql
/opt/lampp/bin/mysqldump --no-data --tables -u root -p GameRound >> GameRound.sql

2012年9月5日 星期三

php namespace


http://www.php.net/manual/en/language.namespaces.definition.php

Although any valid PHP code can be contained within a namespace, only four types of code are affected by namespaces: classes, interfaces, functions and constants

2012年9月4日 星期二

symfony routing



http://symfony.com/doc/current/book/routing.html



Routing with Placeholders

Of course the routing system supports much more interesting routes. Many routes will contain one or more named "wildcard" placeholders:
  • YAML
    1
    2
    3
    blog_show:
        pattern:   /blog/{slug}
        defaults:  { _controller: AcmeBlogBundle:Blog:show }
 The pattern will match anything that looks like /blog/*. Even better, the value matching the {slug} placeholder will be available inside your controller 
by default, all placeholders are required

modify the route to make the {page} parameter optional. This is done by including it in the defaults collection: YAML
1
2
3
blog:
    pattern:   /blog/{page}
    defaults:  { _controller: AcmeBlogBundle:Blog:index, page: 1 }

blog:
    pattern:   /blog/{page}
    defaults:  { _controller: AcmeBlogBundle:Blog:index, page: 1 }
    requirements:
        page:  \d+

Earlier Routes always Win

Suppose you have a contact form with two controllers - one for displaying the form (on a GET request) and one for processing the form when it's submitted (on a POST request). This can be accomplished with the following route configuration: YAML
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
contact:
    pattern:  /contact
    defaults: { _controller: AcmeDemoBundle:Main:contact }
    requirements:
        _method:  GET

contact_process:
    pattern:  /contact
    defaults: { _controller: AcmeDemoBundle:Main:contactProcess }
    requirements:
        _method:  POST

Like the other requirements, the _method requirement is parsed as a regular expression

there are three parameters that are special: each adds a unique piece of functionality inside your application:
  • _controller: As you've seen, this parameter is used to determine which controller is executed when the route is matched;
  • _format: Used to set the request format (read more);
  • _locale: Used to set the locale on the session (read more);

You can also use a special $_route variable, which is set to the name of the route that was matched
All routes are loaded via a single configuration file - usually app/config/routing.yml (see Creating Routes above). Commonly, however, you'll want to load routes from other places, like a routing file that lives inside a bundle. This can be done by "importing" that file:
YAML
1
2
3
# app/config/routing.yml
acme_hello:
    resource: "@AcmeHelloBundle/Resources/config/routing.yml"

When importing resources from YAML, the key (e.g. acme_hello) is meaningless. Just be sure that it's unique so no other lines override it

Prefixing Imported Routes

You can also choose to provide a "prefix" for the imported routes. For example, suppose you want the acme_hello route to have a final pattern of /admin/hello/{name} instead of simply /hello/{name}:
YAML
1
2
3
4
# app/config/routing.yml
acme_hello:
    resource: "@AcmeHelloBundle/Resources/config/routing.yml"
    prefix:   /admin
The string /admin will now be prepended to the pattern of each route loaded from the new routing resource.

A great way to see every route in your application is via the router:debug console command. Execute the command by running the following from the root of your project.
1
$ php app/console router:debug
/opt/lampp/bin/php ~/htdocs/Symfony/app/console router:debug

You can also get very specific information on a single route by including the route name after the command:
1
$ php app/console router:debug article_show

mapping the URL to a controller+parameters and a route+parameters back to a URL. The match() and generate() methods form this bi-directional system. Take the blog_show example route from earlier:
1
2
3
4
5
$params = $router->match('/blog/my-blog-post');//URL to parameters 
// array('slug' => 'my-blog-post', '_controller' => 'AcmeBlogBundle:Blog:show')

$uri = $router->generate('blog_show', array('slug' => 'my-blog-post'));//a route+parameters back to a URL
// /blog/my-blog-post

If the frontend of your application uses AJAX requests, you might want to be able to generate URLs in JavaScript based on your routing configuration. By using the FOSJsRoutingBundle, you can do exactly that:
1
var url = Routing.generate('blog_show', { "slug": 'my-blog-post'});

Generating Absolute URLs

By default, the router will generate relative URLs (e.g. /blog). To generate an absolute URL, simply pass true to the third argument of the generate() method:
1
2
$router->generate('blog_show', array('slug' => 'my-blog-post'), true);
// http://www.example.com/blog/my-blog-post

Generating URLs with Query Strings

The generate method takes an array of wildcard values to generate the URI. But if you pass extra ones, they will be added to the URI as a query string:
1
2
$router->generate('blog', array('page' => 2, 'category' => 'Symfony'));
// /blog/2?category=Symfony

Generating URLs from a template

The most common place to generate a URL is from within a template when linking between pages in your application. This is done just as before, but using a template helper function:
  • Twig
    1
    2
    3
    <a href="{{ path('blog_show', {'slug': 'my-blog-post'}) }}">
      Read this blog post.
    </a>
    
  • PHP
Absolute URLs can also be generated.
Twig
1
2
3
<a href="{{ url('blog_show', {'slug': 'my-blog-post'}) }}">
  Read this blog post.
</a>

symfony Environment


http://symfony.com/doc/current/book/page_creation.html#environments

Before you begin: Create the Bundle

To create a bundle called AcmeHelloBundle (a play bundle that you'll build in this chapter), run the following command and follow the on-screen instructions (use all of the default options):

$ php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml 
/opt/lampp/bin/php /home/d68fbe50/htdocs/Symfony/app/console generate:bundle --namespace=Acme/HelloBundle --format=yml 
Behind the scenes, a directory is created for the bundle at src/Acme/HelloBundle. A line is also automatically added to the app/AppKernel.php file so that the bundle is registered with the kernel:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Acme\HelloBundle\AcmeHelloBundle(),
    );
    // ...

    return $bundles;
}

Environment Configuration

The AppKernel class is responsible for actually loading the configuration file of your choice:
1
2
3
4
5
// app/AppKernel.php
public function registerContainerConfiguration(LoaderInterface $loader)
{
    $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}