Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 912667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:25:20+00:00 2026-05-15T17:25:20+00:00

(I hope ‘bootstrap’ is the correct term…) I have a Symfony 1.4 project in

  • 0

(I hope ‘bootstrap’ is the correct term…)

I have a Symfony 1.4 project in which I’m using a PHP script that mostly contains Javascript (I’m including this script with a simple <script src="/js/myStuff.js"></script> tag). I need to use some Symfony classes, helper methods, and variables from within the script (specifically the sfConfig class, url_for() helper method, and the $sf_request variable.) I’m at a loss as to how to achieve this. I tried copying the code from one of the front controllers into the script, but that ended up outputting the contents of my application’s layout file.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:25:20+00:00Added an answer on May 15, 2026 at 5:25 pm

    You can do what you want by using something like this to create a symfony context:

    require_once($_SERVER['DOCUMENT_ROOT'].'/../config/ProjectConfiguration.class.php');
    
    $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
    $context = sfContext::createInstance($configuration);
    

    To use url_for, you will also need to either load/include the Url helper, which can be done like:

    sfContext::getInstance()->getConfiguration()->loadHelpers('Url');
    

    I think there’s a better approach though:

    Serve this javascript file as symfony action if you need access to symfony – there’s nothing that says you can only serve html through symfony.

    Check out the block here entitled Javascript As An Action for an explanation …

    http://www.symfony-project.org/jobeet/1_2/Doctrine/en/18#chapter_18_user_feedback

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hope you can help me with this: I'm working with j_security_check and have this
Hope you can help me on this. I have a serial device, this device
Hope you are fine. I have a problem, if you can help me. #My
Hope you are fine. My question : In MYSQL i have a table with
I hope I can explain this clearly: I have two tables with the following
Hope everyone is doing well I am having a problem with make files in
Hope someone can advise. Having issues trying to remove a row once a link
Hope the title isn't to confusing wasn't sure how I should put it. I
hope someone can help me on this as been stuck for hours. I am
I hope I can explain this well, if I don't I'll try again. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.