This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » InvalidArgumentException error (jobeet tutorial day 5)
icon9.gif  InvalidArgumentException error (jobeet tutorial day 5) [message #97974] Fri, 23 April 2010 22:52 Go to next message
jsjohns2  is currently offline jsjohns2
Messages: 1
Registered: April 2010
Junior Member
I am attempting to follow the Jobeet tutorial, and am having trouble with day 5. Specifically, the section intended to customize the URL format to "/job/sensio-labs/paris-france/1/web-developer":

The following route works correctly, with non-"slugified" URLs:
job_show_user:
  url:     /job/:company/:location/:id/:position
  class:   sfDoctrineRoute
  options: { model: JobeetJob, type: object }
  param:   { module: job, action: show }
  requirements:
    id: \d+
    sf_method: [get]


However, attempting to use the route which should slugify the URLs:
job_show_user:
  url:     /job/:company_slug/:location_slug/:id/:position_slug
  class:   sfDoctrineRoute
  options: { model: JobeetJob, type: object }
  param:   { module: job, action: show }
  requirements:
    id: \d+
    sf_method: [get]


Produces the following error:
500 | Internal Server Error | InvalidArgumentException
The "/job/:company_slug/:location_slug/:id/:position_slug" route has some missing mandatory parameters (:company_slug, :location_slug, :position_slug).


As far as I can tell, I have followed day 5 exactly. Any help would be greatly appreciated!
Re: InvalidArgumentException error (jobeet tutorial day 5) [message #98105 is a reply to message #97974 ] Tue, 27 April 2010 10:56 Go to previous messageGo to next message
nicolasv  is currently offline nicolasv
Messages: 7
Registered: April 2010
Junior Member
I've the same problem.

This page is working http://www.jobeet.com.localhost/frontend_dev.php/job/sensio- labs/paris-france/1/web-developer

but when I go to http://www.jobeet.com.localhost/frontend_dev.php/

I've this error message :

The "/job/:company_slug/:location_slug/:id/:position_slug" route has some missing mandatory parameters (:company_slug,
 :location_slug, :position_slug).


1	Info sfPatternRouting	Match route "homepage" (/) for / with parameters array ( 'module' => 'job', 'action' => 'index',)
2	Info sfFilterChain	Executing filter "sfRenderingFilter"
3	Info sfFilterChain	Executing filter "sfExecutionFilter"
4	Info jobActions	Call "jobActions->executeIndex()"
5	Info Doctrine_Connection_Mysql	exec : SET NAMES 'UTF8' - ()
6	Info Doctrine_Connection_Mysql	query : SELECT j.id AS j__id, j.category_id AS j__category_id, j.type AS j__type,
 j.company AS j__company, j.logo AS j__logo, j.url AS j__url,
 j.position AS j__position, j.location AS j__location, j.description AS j__description, j.how_to_apply AS j__how_to_apply, j.token AS j__token, j.is_public AS
j__is_public, j.is_activated AS j__is_activated, j.email AS 
j__email, j.expires_at AS j__expires_at, j.created_at AS j__created_at, j.updated_at AS j__updated_at FROM jobeet_job j -
 ()
7	Info sfPHPView	Render "sf_app_dir/modules/job/templates/indexSuccess.php"
8	Error InvalidArgumentException	The "/job/:company_slug/:location_slug/:id/:position_slug"
route has some missing mandatory parameters (:company_slug, :location_slug, :position_slug).
9	Info sfWebResponse	Send status "HTTP/1.1 500 Internal Server Error"
10	Info sfWebResponse	Send header "Content-Type: text/html; charset=utf-8" 


The problem come from the view and url_for helper :

<!-- apps/frontend/modules/job/templates/indexSuccess.php -->
<?php use_stylesheet('jobs.css') ?>

<div id="jobs">
  <table class="jobs">
    <?php foreach ($jobeet_jobs as $i => $job): ?>
      <tr class="<?php echo fmod($i, 2) ? 'even' : 'odd' ?>">
        <td class="location"><?php echo $job->getLocation() ?></td>
        <td class="position">
          <a href="<?php echo url_for('job_show_user', $job) ?>">
            <?php echo $job->getPosition() ?>
          </a>
        </td>
        <td class="company"><?php echo $job->getCompany() ?></td>
      </tr>
    <?php endforeach ?>
  </table>
</div>



A var_dump of the $job object, :

      

object(sfOutputEscaperIteratorDecorator)[93]
  private 'iterator' => 
    object(IteratorIterator)[102]
  protected 'value' => 
    object(JobeetJob)[87]
      protected '_node' => null
      protected '_id' => 
        array
          'id' => string '1' (length=1)
      protected '_data' => 
        array
          'id' => string '1' (length=1)
          'category_id' => string '2' (length=1)
          'type' => string 'full-time' (length=9)
          'company' => string 'Sensio Labs' (length=11)
          'logo' => string 'sensio-labs.gif' (length=15)
          'url' => string 'http://www.sensiolabs.com/' (length=26)
          'position' => string 'Web Developer' (length=13)
          'location' => string 'Paris, France' (length=13)
          'description' => string 'You've already developed websites with symfony and you want to work
with Open-Source technologies. You have a minimum of 3 years
experience in web development with PHP or Java and you wish to
participate to development of Web 2.0 sites using the best
frameworks available.
' (length=273)
          'how_to_apply' => string 'Send your resume to fabien.potencier [at] sensio.com
' (length=53)
          'token' => string 'job_sensio_labs' (length=15)
          'is_public' => boolean true
          'is_activated' => boolean true
          'email' => string 'job@example.com' (length=15)
          'expires_at' => string '2010-10-10 00:00:00' (length=19)
          'created_at' => string '2010-04-20 18:55:24' (length=19)
          'updated_at' => string '2010-04-20 18:55:24' (length=19)
      protected '_values' => 
        array
          empty
      protected '_state' => int 3
      protected '_lastModified' => 
        array
          empty
      protected '_modified' => 
        array
          empty
      protected '_oldValues' => 
        array
          empty
      protected '_errorStack' => null
      protected '_references' => 
        array
          empty
      protected '_pendingDeletes' => 
        array
          empty
      protected '_pendingUnlinks' => 
        array
          empty
      protected '_serializeReferences' => boolean false
      protected '_invokedSaveHooks' => boolean false
      private '_oid' => int 2
      protected '_table' => 
        object(JobeetJobTable)[64]
          protected '_data' => 
            array
              ...
          protected '_identifier' => string 'id' (length=2)
          protected '_identifierType' => int 1
          protected '_conn' => 
            object(Doctrine_Connection_Mysql)[17]
              ...
          protected '_identityMap' => 
            array
              ...
          protected '_repository' => 
            object(Doctrine_Table_Repository)[73]
              ...
          protected '_columns' => 
            array
              ...
          protected '_uniques' => 
            array
              ...
          protected '_fieldNames' => 
            array
              ...
          protected '_columnNames' => 
            array
              ...
          protected 'columnCount' => int 15
          protected 'hasDefaultValues' => boolean true
          protected '_options' => 
            array
              ...
          protected '_tree' => null
          protected '_parser' => 
            object(Doctrine_Relation_Parser)[65]
              ...
          protected '_templates' => 
            array
              ...
          protected '_filters' => 
            array
              ...
          protected '_generators' => 
            array
              ...
          protected '_generator' => null
          protected '_invokedMethods' => 
            array
              ...
          protected 'record' => 
            object(JobeetJob)[66]
              ...
          protected 'attributes' => 
            array
              ...
          protected 'parent' => 
            object(Doctrine_Connection_Mysql)[17]
              ...
          protected '_impl' => 
            array
              ...
          protected '_params' => 
            array
              ...
          protected '_locator' => null
          protected '_resources' => 
            array
              ...
      protected '_locator' => null
      protected '_resources' => 
        array
          empty
  protected 'escapingMethod' => string 'esc_specialchars' (length=16)



The next step it's to read the code but if anyone have an idea thanks in advance.

[Mod: wrapped long lines -- halfer]

[Updated on: Thu, 06 May 2010 10:17] by Moderator


http://twitter.com/n_vogel
Re: InvalidArgumentException error (jobeet tutorial day 5) [message #98232 is a reply to message #97974 ] Wed, 28 April 2010 21:54 Go to previous messageGo to next message
nicolasv  is currently offline nicolasv
Messages: 7
Registered: April 2010
Junior Member
Any idea for debugging this ?

my JobeetJob Class (lib/model/doctrine/JobeetJob.class.php)



<?php

class JobeetJob extends BaseJobeetJob {
    
    public function __toString() {
        return sprintf('%s at %s (%s)', $this->getPosition(), $this->getCompany(), $this->getLocation());
    }
    
    public function getCompanySlug() {
        //return Jobeet::slugify($this->getCompany());
        $text = $this->getCompany();
        $text = preg_replace('/\W+/', '-', $text);
        // trim and lowercase
        $text = strtolower(trim($text, '-'));
        return $text;
    }
    
    public function getPositionSlug() {
        // return Jobeet::slugify($this->getPosition());
        $text =  $this->getPosition();
        $text = preg_replace('/\W+/', '-', $text);
        // trim and lowercase
        $text = strtolower(trim($text, '-'));
        return $text;
    }
    
    public function getLocationSlug() { 
        // return Jobeet::slugify($this->getLocation());
        $text =  $this->getLocation();
        $text = preg_replace('/\W+/', '-', $text);
        // trim and lowercase
        $text = strtolower(trim($text, '-'));
        return $text;  
    }
    
    
}


The job_show_user route

php symfony app:routes frontend job_show_user

>> app       Route "job_show_user" for application "frontend"
Name         job_show_user
Pattern      /job/:company_slug/:location_slug/:id/:position_slug
Class        sfDoctrineRoute
Defaults     action: 'show'
             module: 'job'
Requirements company_slug: '[^/\\.]+'
             id: '\\d+'
             location_slug: '[^/\\.]+'
             position_slug: '[^/\\.]+'
             sf_method: array (0 => 'get',)
Options      cache: NULL
             context: array ()
             debug: true
             default_action: 'index'
             default_module: 'default'
             extra_parameters_as_query_string: true
             generate_shortest_url: true
             load_configuration: false
             logging: false
             lookup_cache_dedicated_keys: false
             model: 'JobeetJob'
             segment_separators: array (0 => '/',1 => '.',)
             segment_separators_regex: '(?:/|\\.)'
             suffix: ''
             text_regex: '.+?'
             type: 'object'
             variable_content_regex: '[^/\\.]+'
             variable_prefix_regex: '(?:\\:)'
             variable_prefixes: array (0 => ':',)
             variable_regex: '[\\w\\d_]+'
Regex        #^/job/(?P<company_slug>[^/\.]+)/(?P<location_slug>[^/\.]+)/(?P<id>\d+)/(?P<position_slug>[^/\.]+)$#x
Tokens       separator  array (0 => '/',1 => NULL,)
             text       array (0 => 'job',1 => NULL,)
             separator  array (0 => '/',1 => NULL,)
             variable   array (0 => ':company_slug',1 => 'company_slug',)
             separator  array (0 => '/',1 => NULL,)
             variable   array (0 => ':location_slug',1 => 'location_slug',)
             separator  array (0 => '/',1 => NULL,)
             variable   array (0 => ':id',1 => 'id',)
             separator  array (0 => '/',1 => NULL,)
             variable   array (0 => ':position_slug',1 => 'position_slug',)


http://twitter.com/n_vogel
Re: InvalidArgumentException error (jobeet tutorial day 5) [message #98245 is a reply to message #98232 ] Thu, 29 April 2010 08:32 Go to previous messageGo to next message
ipatate  is currently offline ipatate
Messages: 1
Registered: April 2010
Location: Paris
Junior Member
met des strings en dur dans chaques méthodes get...slug() pour voir si ça vient de là.
Sinon t'aurais pas oublier options: { model: JobeetJob, type: object } dans le routing, et du coup il sait pas ou demander les methodes et donc ça fait null ??
Re: InvalidArgumentException error (jobeet tutorial day 5) [message #98275 is a reply to message #98245 ] Thu, 29 April 2010 16:57 Go to previous messageGo to next message
nicolasv  is currently offline nicolasv
Messages: 7
Registered: April 2010
Junior Member
I don't know for sure why but it's working now, I installed xdebug, made somes tests, I ran the "./symfony cache:clear" task,
and now it's working with the same code presented in the Jobeet tutorial Shocked

Is it possible that the clear cache solved the problem ?

I'am back on track for the day 6 and with a debugger now Very Happy

Thanks for the help ipatate

./symfony cache:clear
>> cache     Clearing cache type "all" for "frontend" app and "dev" env
>> file+     /mnt/hgfs/projects/netbeen/jobeet/data/frontend_dev-cli.lck
>> chmod 777 /mnt/hgfs/projects/netbeen/jobeet/data/frontend_dev-cli.lck
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/modules_job_config_view.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/modules_job_config_security.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/modules_job_config_module.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/modules_job_config_filters.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/modules_default_config_view.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/modules_default_config_security.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/modules_default_config_module.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/modules_default_config_filters.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/config_settings.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/config_routing.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/config_factories.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/config_databases.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/config_config_handlers.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/config_autoload.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/dev/config/config_app.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/data/frontend_dev-cli.lck
>> cache     Clearing cache type "all" for "frontend" app and "prod" env
>> file+     /mnt/hgfs/projects/netbeen/jobeet/data/frontend_prod-cli.lck
>> chmod 777 /mnt/hgfs/projects/netbeen/jobeet/data/frontend_prod-cli.lck
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/modules_job_config_security.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/modules_job_config_module.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/modules_job_config_filters.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/modules_default_config_view.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/modules_default_config_security.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/modules_default_config_module.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/modules_default_config_filters.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/config_settings.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/config_routing.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/config_factories.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/config_databases.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/config_core_compile.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/config_config_handlers.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/config_autoload.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/prod/config/config_app.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/data/frontend_prod-cli.lck
>> cache     Clearing cache type "all" for "frontend" app and "test" env
>> file+     /mnt/hgfs/projects/netbeen/jobeet/data/frontend_test-cli.lck
>> chmod 777 /mnt/hgfs/projects/netbeen/jobeet/data/frontend_test-cli.lck
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/test/config/config_settings.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/test/config/config_config_handlers.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/cache/frontend/test/config/config_app.yml.php
>> file-     /mnt/hgfs/projects/netbeen/jobeet/data/frontend_test-cli.lck


http://twitter.com/n_vogel
Re: InvalidArgumentException error (jobeet tutorial day 5) [message #98402 is a reply to message #98275 ] Sun, 02 May 2010 19:34 Go to previous messageGo to next message
lkrubner  is currently offline lkrubner
Messages: 297
Registered: July 2008
Location: Virginia, USA
Faithful Member
Is it possible that the clear cache solved the problem ?


Any time you make any change to a yaml file, you need to run the command "symfony cc" (which is a short version of "symfony clear-cache").

It is a bit of a pain, but once you've been working with Symfony for a week or two, you realize that a lot of problems are solved simply by clearing the cache.



Symfony Experts offers answers: http://www.symfonyexperts.com/
Re: InvalidArgumentException error (jobeet tutorial day 5) [message #98598 is a reply to message #97974 ] Thu, 06 May 2010 10:14 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
I think this has been answered before here. Try changing:

<?php echo url_for('job_show_user', $job) ?>

to

<?php echo url_for('@job_show_user', $job) ?>

[Updated on: Thu, 06 May 2010 10:16]


Remember Palestine
Re: InvalidArgumentException error (jobeet tutorial day 5) [message #98599 is a reply to message #97974 ] Thu, 06 May 2010 10:28 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
I take my last comments back - it was a different issue last time - same `@` solution!

@jsjohns2 or @nicolasv, could I trouble you to raise a ticket for this?


Remember Palestine
Re: InvalidArgumentException error (jobeet tutorial day 5) [message #103442 is a reply to message #98599 ] Mon, 02 August 2010 23:03 Go to previous messageGo to next message
armakan  is currently offline armakan
Messages: 1
Registered: August 2010
Location: Cookeville, TN
Junior Member
I've discovered this same problem, and have tried this:

<?php echo url_for('@job_show_user', $job) ?>


and still get the same error, even after clearing the cache as well. What's going on here? Any ideas on how to fix this, or am I just going to have to not use the slugify feature or switch to a different php framework?
Re: InvalidArgumentException error (jobeet tutorial day 5) [message #103459 is a reply to message #97974 ] Tue, 03 August 2010 10:11 Go to previous message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
You can switch to a different framework if you wish, but this one does work very well for us Very Happy

I've a partially-completed tarball for the Propel version, maybe it might help?


Remember Palestine
Previous Topic:backend login redirects to the frontend homepage
Next Topic:Error with include_once()
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software