在symfony中禁用路由缓存

时间:2016-01-24 13:33:12

标签: php symfony

我正在尝试开始使用symfony3并且在玩一些控制器和路由时我面临的问题是,每次加载特定路由时,symfony都无法识别控制器类上的任何进一步更改,直到我清除路由高速缓存中。

例如:

创建LuckyController

创建一个numberAction

测试它。

之后创建numbers2Action

现在找不到numbers2Action的路由,直到我进行控制台缓存:清除

这对于测试/开发来说似乎非常烦人。我搜索了为开发环境禁用缓存的可能性,但还没有找到解决方案。 (例如尝试// $ kernel-> loadClassCache();在app_dev.php中,但这对我没用)

是否有办法禁用路由缓存(或其他解决此问题的方法)进行开发?

由于

编辑:我正在使用app_dev.php

1 个答案:

答案 0 :(得分:2)

您可以在开发或调试应用程序时使用symfony标准的特定开发环境:app_dev.php。您可以使用public static class Mapper1 extends Mapper<Object, Text, Text, Text> { private Text word = new Text(); private final static Text identifier = new Text("a"); public void map(Object key, Text value, Context context) throws IOException, InterruptedException { StringTokenizer itr = new StringTokenizer(value.toString()); while (itr.hasMoreTokens()) { word.set(itr.nextToken()); context.write(word,identifier); } } } public static class Reducer extends Reducer<Text, Text, Text, IntWritable> { private IntWritable commoncount = new IntWritable(); public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException { int count1 = 0; int count2 = 0; for (Text val : values) { if(val.equals("a")) count1++; else if(val.equals("b")) count2++; } if (count1 != 0 && count2 != 0) context.write(key,new IntWritable(count1 <= count2 ? count1: count2)); } } public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException { Configuration conf = new Configuration(); Job job1 = new Job(conf, "Testing"); job1.setJarByClass(CommonWords.class); job1.setMapOutputKeyClass(Text.class); job1.setMapOutputValueClass(Text.class); job1.setOutputKeyClass(Text.class); job1.setOutputValueClass(IntWritable.class); job1.setReducerClass(reduce.class); job1.setMapperClass(Mapper1.class); job1.setMapperClass(Mapper2.class); MultipleInputs.addInputPath(job1, new Path(args[0]), KeyValueTextInputFormat.class, Mapper1.class); MultipleInputs.addInputPath(job1, new Path(args[1]), KeyValueTextInputFormat.class, Mapper2.class); FileOutputFormat.setOutputPath(job1, new Path(args[2])); job1.waitForCompletion(true); } } 进行制作。