SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    41
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Silex: development question

    Hi

    Second question of the day in regards to Silex.

    Suppose I have this piece of code:
    Code PHP:
    $app->get('/mails/', function() use($app) {
    	   return $app['twig']->render('index.html', array(
    			'object' => getObject(),
    		));
    	});

    Where do I place the getObject function? Do I just leave it in the index.php file, or do I create a new file and just include the new php file?

    ---------------------------------------------
    Is it still possible to create own classes, as if you weren't using a framework, or is there another way to create a class (a service maybe?)?

    Thx!

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,266
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Silex was designed for building single-file apps, so without knowing more about your code, I'd suggest keeping that function in index.php.
    "First make it work. Then make it better."

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    41
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ok :-) i only have 2 routes defined and will only have 2 functions including the getObject one :-)

    thx


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •